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 <[email protected]> wrote:
From: Cor <[email protected]>
Subject: RE: [Flashcoders] loop and Timer problem?????????
To: "'Flash Coders List'" <[email protected]>
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 (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 don’t."
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of nasim hhhhh
Sent: maandag 29 augustus 2011 19:55
To: [email protected]
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
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders