Friday, March 26, 2010

Running a timer only when the...

Inside a canvas I have a timer that I only want to run while that canvas is visible.?I tried the addededToStage and removedFromStage events which started the timer as soon as I launched the app.?I figured this must be a pretty common thing to do so rather than trying every event that souds like it might work and maybe getting lucky I would just ask.

Thanks!

Running a timer only when the...

How do you change the visible status of your Canvas? If it's for example by some user-action (f.e. Button-Click) you can simply add a start/stop-Timer call to that...But I think you change it in a different way, don't you?

Running a timer only when the...

Yeah, a button click is out of the question.?It is the main page in a module and there are a 1000 ways in and out of it.?I really need to key on some event.?

Found the answer.?The DisplayObject has a boolean property called strangely enough ''visible''.?So I can do something like this:

private function myTimerEventHandler(event:TimerEvent):void{

if(this.visible){

?//do whatever

}

}

No comments:

Post a Comment