請問該如何才能從屬性指向其類別的實體?
例如我有一個類別Apple,裡面有屬性boolean和Timer
我要在Main.as裡作到stopGrow()裡說的要求:
//===(Apple.as)
public class Apple extends MovieClip{
var growTimer:Timer;
var canEat:Boolean;
}
//===(Main.as)
var apple1=new Apple();
startGrow(apple1);
public function startGrow(temp:Object){
var tempA=temp;
tempA.canEat=flase;
tempA.growTimer = new Timer(1000,1);
tempA.growTimer.addEventListener(TimerEvent.TIMER_COMPLETE, stopGrow);
tempA.growTimer.start();
}
public function stopGrow(evt:TimerEvent):void
{
/*該如何用evt.target指向apple1實體,讓apple1.canEat=false;*/
}
想知道這種情況下的寫法
感謝先進指點!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.32.90.140
※ 編輯: justaID 來自: 114.32.90.140 (11/22 05:06)