Eka, was right about the notation being the problem but I thought I would mention something small I noticed.

You declare delay as a private property of the class but then declare it again as a local variable inside your doSomething() method. If you don't need to access the value of delay outside of the doSomething() method I would remove it at a private property of the class. Otherwise, if you do need it outside of the doSomething method I would remove the var keyword from in front of the assignment so that you are assigning to the class' property and not creating a new local variable.

You might also want to be consistant with your variable names. You prefix Time with n for a Number but don't do so with delay.

Also, you can check out my Timer class for something like this:
http://www.jamesor.com/2006/10/18/as2-timer-class/


James O'Reilly  —  Consultant
Adobe Certified Flash Expert
http://www.jamesor.com
Design • Code • Train



eric e. dolecki wrote:
I have a simple class and I can't access a private var after using
setTimeout... I typed this up to show whats happening:

class foo extends MovieClip
{
private var nTime:Number = 0.75;
private var delay:Number;

function foo()
{
// stuff
};

public function doSomething():Void
{
trace( nTime ); // works fine [0.75]
var delay = _global.setTimeout( delayedFunc, 1000 );
};

private function delayedFunc():Void
{
trace( nTime ); //undefined ?
};
}

?? I could use setInterval and kill it after the first fire, but setTimeout
is nicer. This is AS2 obviously.

- eric
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to