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()
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 {
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;
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
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
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
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
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:
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
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
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
11 matches
Mail list logo