Re: [問題]如何讓物件跟著滑鼠動
另外宣告一個 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)
推
12/10 00:55, , 1F
12/10 00:55, 1F
→
12/10 01:42, , 2F
12/10 01:42, 2F
討論串 (同標題文章)
Flash 近期熱門文章
PTT數位生活區 即時熱門文章