Re: [Flashcoders] loop and Timer problem?????????
thx --- On Mon, 8/29/11, Kerry Thompson al...@cyberiantiger.biz wrote: From: Kerry Thompson al...@cyberiantiger.biz Subject: Re: [Flashcoders] loop and Timer problem? To: Flash Coders List flashcoders@chattyfig.figleaf.com Date: Monday, August 29, 2011, 6:28 PM The timer isn't completely independent. If there is code executing when it is time for the timer to fire, the timer has to wait until the code finishes. Loops are notorious CPU hogs--nothing else can happen until the loop finishes. Cordially, Kerry Thompson On Aug 29, 2011, at 3:27 PM, nasim h iranebah...@yahoo.com wrote: I Cant understad 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 (counter1000) { 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] loop and Timer problem?????????
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 (counter1000) { //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 h 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(counter1000) { 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
RE: [Flashcoders] loop and Timer problem?????????
in main i call testhalgheh(); so inside it timer will start it stuck in loop untill it get true in logic I think when the timer start it shouldnt related to thing so during loop the timer event should work and code if(generalFlag==true) { trace(hello) counter+=1; } should work but the test show the flag doest get true why is that the timer shoudl work independently --- 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:01 PM 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 (counter1000) { //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 don’t. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim h 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(counter1000) { 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 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] loop and Timer problem?????????
in main i call testhalgheh(); so inside it timer will start Cor: Yes, but your Timer gets create 1 line below your function caal, so at that moment it does not exist. it stuck in loop untill it get true in logic I think when the timer start it shouldnt related to thing so during loop the timer event should work and code if(generalFlag==true) { trace(hello) counter+=1; } should work but the test show the flag doest get true why is that the timer shoudl work independently Cor: No, and the function generalFlag does not do anything because it stays true --- 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:01 PM 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 (counter1000) { //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 don’t. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim h 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(counter1000) { 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 ___ 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
RE: [Flashcoders] loop and Timer problem?????????
This loop is running and your timer callback function has not yet set the Boolean to true while (counter1000) { if (generalFlag==true) { trace(hello); counter++; } } And then it get in the infinite loop 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 don’t. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim h Sent: maandag 29 augustus 2011 20:29 To: Flash Coders List Subject: RE: [Flashcoders] loop and Timer problem? in main i call testhalgheh(); so inside it timer will start it stuck in loop untill it get true in logic I think when the timer start it shouldnt related to thing so during loop the timer event should work and code if(generalFlag==true) { trace(hello) counter+=1; } should work but the test show the flag doest get true why is that the timer shoudl work independently --- 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:01 PM 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 (counter1000) { //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 don’t. -Original Message- From: flashcoders-boun...@chattyfig.figleaf.com [mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of nasim h 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(counter1000) { 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 ___ 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
RE: [Flashcoders] loop and Timer problem?????????
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 (counter1000) { if (generalFlag==true) { trace(hello); counter++; } } } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] loop and Timer problem?????????
I Cant understad 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 (counter1000) { 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
RE: [Flashcoders] loop and Timer problem?????????
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 h Sent: maandag 29 augustus 2011 21:27 To: Flash Coders List Subject: RE: [Flashcoders] loop and Timer problem? I Cant understad 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 (counter1000) { 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
Re: [Flashcoders] loop and Timer problem?????????
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 h Sent: maandag 29 augustus 2011 21:27 To: Flash Coders List Subject: RE: [Flashcoders] loop and Timer problem? I Cant understad 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 (counter1000) { 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
Re: [Flashcoders] loop and Timer problem?????????
We can see why this approach doesn't work, but maybe if you said what your trying to accomplish, then a working solution could be offered. John On Aug 29, 2011, at 3:18 PM, Ktu wrote: 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. John R. Sweeney Jr. Senior Interactive Multimedia Developer OnDemand Interactive Inc Hoffman Estates, IL 60169 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] loop and Timer problem?????????
The timer isn't completely independent. If there is code executing when it is time for the timer to fire, the timer has to wait until the code finishes. Loops are notorious CPU hogs--nothing else can happen until the loop finishes. Cordially, Kerry Thompson On Aug 29, 2011, at 3:27 PM, nasim h iranebah...@yahoo.com wrote: I Cant understad 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 (counter1000) { 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