1. You call the function but your timer does not exist 2 your Boolean never get true so your loop in infinite.
Try this: var forsate,generalFlag:Boolean; var counter:int=0; var generalTimer:Timer=new Timer(10); testhalgheh(); function generalfunc(e:TimerEvent=null):void { generalFlag=true; //trace( " generalFlag " + generalFlag) } function testhalgheh():void { generalTimer.addEventListener(TimerEvent.TIMER,generalfunc); generalTimer.start(); while (counter<1000) { //if (generalFlag==true) { trace("hello"); counter+=1; //} } } Best regards, Cor van Dooren www.codobyte.com ------------------------------------------------------------------ "There are only 10 types of people in the world: Those who understand binary and those who dont." -----Original Message----- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim hhhhh Sent: maandag 29 augustus 2011 19:55 To: Flashcoders@chattyfig.figleaf.com Subject: [Flashcoders] loop and Timer problem????????? what is the problem ? how Timer work that the loop stuck in the program???????????? I cant understand the loop and Timer increase cpu usage?????? var forsate,generalFlag :Boolean; var counter:int; var generalTimer:Timer = new Timer(1); testhalgheh() generalTimer.addEventListener(TimerEvent.TIMER,generalfunc); function generalfunc(e:TimerEvent=null):void { generalFlag=true; //trace( " generalFlag " + generalFlag) } function testhalgheh():void { generalTimer.start(); while(counter<1000) { if(generalFlag==true) { trace("hello") counter+=1; } } } _______________________________________________ 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