Re: [問題]如何讓物件跟著滑鼠動

看板Flash作者 (CJ Cat)時間17年前 (2008/11/27 10:02), 編輯推噓1(101)
留言2則, 2人參與, 最新討論串2/4 (看更多)
另外宣告一個 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
尤記得初學時不知道有startDrug() 只好用TIMER來做^^"
12/10 00:55, 1F

12/10 01:42, , 2F
↑start drug? 開始嗑藥? XD
12/10 01:42, 2F
文章代碼(AID): #19BV-QCO (Flash)
文章代碼(AID): #19BV-QCO (Flash)