YOGESH JADHAV escreveu:
> Hi Frederico,
>                     The Alert is pop uped after some time interval. 
> For first time it is ok, i.e. 3 seconds, but after that it vanishes 
> much before 3 seconds, many times less than 1 second and sometimes it 
> just flashes, can't be seen.
>           My concept of timer is not that clear, It will be great if u 
> provide some timing snipeet using On Enter Frame.
> On Jan 7, 2008 3:19 PM, Frederico Garcia < [EMAIL PROTECTED] 
> <mailto:[EMAIL PROTECTED]>> wrote:
>
>     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
>     <http://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
>
>
>
>
> -- 
> There is no point in knocking the "closed Windows" when the door is 
> "Open". Open your eyes, use open source software.
>
>
> Regards,
> Yogesh 
>
> __________ NOD32 2769 (20080107) Information __________
>
> This message was checked by NOD32 antivirus system.
> http://www.eset.com
Hi,

You got me in good mood so here's an example covering both the Timer and 
onEnterFrame timing techniques: http://www.kemelyon.com/timing_example/ 
(right click to view source).

Near the end of making you the example I figured out what was wrong in 
your code. Really simple, so simple I often forget it. STOPPING THE 
TIMER! :) imagine you set the timer to trigger every 3 seconds; after 
one second you close the alert; after half a second you open the alert 
again. After half a second the Timer would trigger and your new born 
alert would be closed.

Tell me if this helped,

Frederico Garcia

Reply via email to