A stack needs to finish and a new frame needs to enter for the Timer to
actually dispatch its TimerEvent.TIMER. Since the while loop is never ending
( because the timer can't dispatch and change the boolean), the stack never
ends. Thus, infinite loop.



On Mon, Aug 29, 2011 at 3:28 PM, Cor <c...@chello.nl> wrote:

> It does not effect your CPU, but because of the never ending loop, your app
> crashes.
>
> Best regards,
> Cor
>
>
> -----Original Message-----
> From: flashcoders-boun...@chattyfig.figleaf.com
> [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim
> hhhhh
> Sent: maandag 29 augustus 2011 21:27
> To: Flash Coders List
> Subject: RE: [Flashcoders] loop and Timer problem?????????
>
> I Cant understannnnnnnnnnnnd
> why is that
> when the timer start it should work independence any thing but it wait for
> finish th loop can u explain the timer and loop i know them but i cant
> understand how they work and has an effect on cpu
>
> --- On Mon, 8/29/11, Cor <c...@chello.nl> wrote:
>
> From: Cor <c...@chello.nl>
> Subject: RE: [Flashcoders] loop and Timer problem?????????
> To: "'Flash Coders List'" <flashcoders@chattyfig.figleaf.com>
> Date: Monday, August 29, 2011, 2:44 PM
>
> TRY THIS:
>
>
> var forsate,generalFlag:Boolean;
> var counter:int=0;
> var generalTimer:Timer=new Timer(1);
> generalTimer.addEventListener(TimerEvent.TIMER,generalfunc);
>
> //NOW IT IS SET
> //UN COMMENT THE LINE BELOW TO NOTICE THE DIFFENCE //generalFlag=true;
>
> testhalgheh();
>
> function generalfunc(e:TimerEvent=null):void {
>     generalFlag=true;
>     //trace( " generalFlag " + generalFlag) }
>
> function testhalgheh():void {
>     generalTimer.start();
>     //generalFlag IS FALSE AT THIS MOMENT, BECAUSE THE generalfunc IS NOT
> YET CALLED
>     while (counter<1000) {
>         if (generalFlag==true) {
>             trace("hello");
>             counter++;
>         }
>     }
> }
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
>
> _______________________________________________
> Flashcoders mailing list
> Flashcoders@chattyfig.figleaf.com
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
Ktu;

The information contained in this message may or may not be privileged
and/or confidential. If you are NOT the intended recipient, congratulations,
you got mail!
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to