Newbie: calling refresh on a the application container from an .as file
I've inherited an application and am fixing a bug. There is a refresh button in a the application's mxml file and it has a click="refresh(null)". This works.
However we also want to do a refresh every five minutes auto开发者_如何学编程matically using a timer. There is code in an .as file (that is sourced' into the above mxml file) that uses a Timer and calls refresh(null) from within the .as file, but this doesn't seem to do anything.
Is this the right way to do this? Or do we need to explicitly reference the object we want to refresh? If so, how do we do that?
Code jisting (sorry, I'm on an isolated network and can't easily move code to here; if you can't read it then just ignore my question please):
foo.mxml:
<mx:Application ...>
<mx:Script source="funcs.as"/>
<mx:Image ... click="refresh(null)".../>
funcs.as:
// timer created
// timer started
// timer observer added, calls refreshScreen()
private function refreshScreen():void
{
refresh(null);
}
var timer:Timer = new Timer( 5000 );// 5 second intervals
timer.addEventListener(TimerEvent.TIMER, refreshScreen)
timer.start( )
//refreshScreen needs to have an event parameter
private function refreshScreen( e:TimerEvent ):void
{
refresh(null);
}
精彩评论