Nick
There is a way to achieve what you are doing... Without hogging CPU
cycles...
callLater(method:Function, args:Array)
This executes on the next redraw cycle. In effect its a cheap way to
incur a "Mutliwait" facility.
So to do what you are thinking about... You could do...
var _checkCondition:Boolean = false;
protected function __checkCondition():void {
if (!_checkCondition) {
callLater(__checkCondition);
else {
__executeThisWhenImTrue();
}
}
protected function __executeThisWhenImTrue():void {
trace("yahooo");
}
public init():void {
__checkCondition();
}
Obviously, an external function would set the value of
_checkCondition... But this isnt a CPU hog and achieves (i think) what
you are after. You could also just use a timer of course...
The great thing about the timer option is that obviously it is
possible to abort easily.. Using callLater, you'd have to be very
careful but its nicer as u can gaurentee that updates occur on the
next frame-draw.
var _timer:Timer = new Timer(1000,1);
var _checkCondition:Boolean = false;
_timer.addEventListener(__checkCondition, false, 0, true);
protected function __checkCondition(_event:TimerEvent=null):void {
if (_checkCondition) {
__executeThisWhenImTrue();
} else {
_timer.reset();
_timer.start();
}
}
protected function __executeThisWhenImTrue():void {
trace("yahooo");
}
public function init():void {
_timer.start();
}
Hope you have fun...
Regards,
Samuel
On Aug 27, 2009, at 7:00 PM, Nick Middleweek wrote:
Tracy/ Beau...
Thanks for your replies...That's helped me understand how things
work a bit more...
I'm going to try it though! haha :-)
Cheers,
Nick
2009/8/27 Tracy Spratt <[email protected]>
Flex procedural code is essentially single threaded. The loop will
stop all other processing, the handler will never get called, and
the loop will never stop.
There is NO sleep or delay or pause or anything like that in Flex.
You must use events.
Tracy Spratt,
Lariat Services, development services available
From: [email protected] [mailto:[email protected]]
On Behalf Of Nick Middleweek
Sent: Thursday, August 27, 2009 6:43 AM
To: [email protected]
Subject: Re: [Spam] RE: [Spam] [flexcoders] Question on Flex Script
Execution + Alert.show
Why won't it work? I can't see why it wouldn't... I'm still learning
Flex so perhaps I've overlooked something.
I do agree, it is bad coding but I can't see why it wouldn't work.
The boolAlertContinue variable is in affect acting like semaphore...
Cheers,
Nick
2009/8/27 Tracy Spratt <[email protected]>
No, no, no, this will not work. You must use the event mechanism.
Tracy Spratt,
Lariat Services, development services available
From: [email protected] [mailto:[email protected]]
On Behalf Of Nick Middleweek
Sent: Wednesday, August 26, 2009 7:33 PM
To: [email protected]
Subject: Re: [Spam] [flexcoders] Question on Flex Script Execution +
Alert.show
I'm not sure if this technique is frowned upon but...
You could have a new private var boolAlertContinue:Boolean = false;
In your alertHandler function, you would set it to true...
boolAlertContinue = true;
And after the Alert.show and before the if(myAlert == 1) you need to
do a do while loop...
do {
//Not sure if there's a 'dummy' command to prevent CPU hog so
we'll just check the time...
var dtmNow:Date = new Date();
}
while (boolAlertContinue);
or you could probably initialise your myAlert:int = null and in the
do ..
Disclaimer
_____________________________________
The information transmitted is intended only for the person or entity to which
it is addressed
and may contain confidential and/or privileged material. Any review,
retransmission, dissemination
or other use of, or taking of any action in reliance upon, this information by
persons or entities
other than the intended recipient is prohibited. If you received this in error,
please contact the
sender and delete the material from your computer. Thank you.