With my hands on a Flash CS3 trial, I’ve created an AS3 version of the Later class.
Source:
I’ve also updated the AS2 version, and now both versions have grouping functionality. So you can now assign a group number to a Later call and abort/finish them by groups.
Note that the method has changed slightly.
Example:
Later.exec(this, foo, 1, true, 0, “bar”);
arg 1 (this) = Object where the function lives.
arg 2 (foo) = Function to call.
arg 3 (1) = Number of frames or milliseconds after which to call the given function.
arg 4 (true) = true = seconds, false = frames
arg 5 (0) = Group number to assign to the call. Default = 0.
arg 6+ (”bar”) = Array of arguments to pass to the given function.
The 5th argument is a uint that assigns a group to the Later object.
Use Later.getUniqueGroup() to ensure unique group numbers.
import com.foomonger.utils.Later;
function foo(bar:String):Void {
trace(”foo = ” + bar);
}
var myGroup:uint = Later.getUniqueGroup();
Later.exec(this, foo, 12, false, myGroup, “hello world”);
Later.exec(this, foo, 13, false, myGroup, “hello world”);
Later.exec(this, foo, 14, false, 0, “hello moon”);
Later.abortGroup(myGroup);
This traces out only “hello moon”.