YOGESH JADHAV escreveu:
> Hi all,
>               I want a reliable timer in my app to remove a alert 
> after say 3 seconds. Earlier I tried the normal setTimeOut but it is 
> not reliable and gives error in firefox. So i tried with onEnterFrame  
> technique, but it is also not working properly. I also tried by 
> setting application frame rate to some value ( like 99, 70 etc). I 
> have seen many application which are having perfect and reliable 
> timing events. Can anybody guide me to achieve perfect timing event. 
> Code snippets will be more than appreciated.
> Here is my code
>
>               private function showMyAlert():void
>               {
>                     alert = Alert.show(" Test, shud be gone in 3 
> seconds");
>                     //setTimeout(hideAlert, 3000);
>                    onCreationComplete();
>              }
>
>
>             private function hideAlert():void
>             {
>                 PopUpManager.removePopUp(alert);
>             }
>            
>             private function alertCloseHnadler(event:CloseEvent):void
>             {
>                 if (event.detail == Alert.YES)
>                     Alert.show("Yes");
>             }
>            
>             private function onCreationComplete() : void
>             {
>                 timer = new Timer(3000);
>                 timer.addEventListener( TimerEvent.TIMER, onTimerEvent );
>                 timer.start ();
>                 fps = 0;
>                 this.addEventListener(Event.ENTER_FRAME, onFrameEnter);
>                
>             }
>            
>             private function onFrameEnter( event : Event ) : void
>             {
>                 fps++;
>                 trace("enterframe");
>             }
>            
>             private function onTimerEvent( event : Event ) : void
>             {
>                hideAlert();
>             }
>            
>
> -- 
> There is no point in knocking the "closed Windows" when the door is 
> "Open". Open your eyes, use open source software.
>
>
> Regards,
> Yogesh 
>
> __________ NOD32 2760 (20080102) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
Hi,

The code for Timer should work. Not advisable to use at the same time as 
onEnterFrame. Either Timer or onEnterFrame are susceptible to CPU usage. 
But with such an interval (3secs) you should have no problem.

I've used Timer to make a clock (www.kemelyon.com) and it's exact in 
seconds.

How big is the error for Timer (and it takes longer or less than expected)?

Regards,

Frederico Garcia

Reply via email to