作者cjcat2266 (CJ Cat)
看板Flash
標題Re: [問題]如何讓物件跟著滑鼠動
時間Thu Nov 27 10:02:00 2008
另外宣告一個 currentResistor 來紀錄最新生出來的 Resistance
然後監聽 stage 丟出來的 MouseEvent.MOUSE_UP 來停止拖曳
(題外話,你變數宣告最好都有標明type,這樣比較安全)
//新宣告
var currentResistor:Resistance;
function markResistance(e){
//省略一些code
//保留住最新生出來的 Resistance 的 reference
currentResistor = resistance;
//監聽stage的MouseEvent.MOUSE_UP
stage.addEventListener(MouseEvent.MOUSE_UP, up);
//開始拖曳
resistance.startDrag();
}
function up(e:Event):void {
//取消監聽
stage.removeEventListener(MouseEvent.MOUSE_UP, up);
//題整拖曳
currentResistor.stopDrag();
}
--
CJ Cat = Croa'J Cat = Cockroach Cat = 西街凱特 = 蜚蠊貓 = 蟑螂貓
Blog
http://cjcat.blogspot.com
Gallery
http://cjcat2266.deviantart.com
ptt2 Board CJWorkshop - 阿多比閃光(Adobe Flash)研討區
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 61.228.79.80
※ 編輯: cjcat2266 來自: 61.228.79.80 (11/27 10:09)
推 klit1987:尤記得初學時不知道有startDrug() 只好用TIMER來做^^" 12/10 00:55
→ cjcat2266: ↑start drug? 開始嗑藥? XD 12/10 01:42