Flash wait time until,,,
Out of context: Reply #9
- Started
- Last post
- 11 Responses
- Jerry0
Probably, the proprt key to the issue is called "event based programming". Flash has some nice undocumented features for this. Called "ASbroadCaster". Wait and let me fix you up an example.
I've written the class below.
////////////////////////////////...
//
// PAUSE CLASS, v1.1
// Jerry van Heerikhuize, 2004
//
////////////////////////////////...
//
// EXAMPLE :
//
//------------------------------...
// MyListener = {};
//
// MyListener.idle = function (ID, state, msg) {
// if (state) {
// trace ("asset" + ID + ": " + msg);
// } else {
// trace ("asset" + ID + " error: " + msg);
// }
// };
//
// asset1 = new PAUSE (5000, "idle", 1);
// asset1.addListener (MyListener);
//
////////////////////////////////...
//
// Method (Public): PAUSE (ID, t, listener, cbf)
//
// ID = instance id (number)
// t = time (number) in microseconds
// listener = listener (obj)
// cbf = callBackFunction (string)
//
_global.PAUSE = function (ID, t, listener, cbf) {
ASBroadCaster.initialize (this);
this.addListener (listener)
//
this.ID = ID;
this.cbf = cbf;
this.timeout = t;
this.starttime = getTimer ();
this.interval = setInterval (this.go, 1, this);
};
////////////////////////////////...
//
// Method (Private): go (obj)
//
// obj = object referance (object)
//
PAUSE.prototype.go = function (obj) {
//
obj.currenttime = getTimer ();
//
var idle = obj.currentTime - obj.starttime >= obj.timeout;
if (idle) {
clearInterval (obj.interval);
obj.broadcastMessage (obj.cbf, obj.ID, true, "done");
}
};
//
//
actionLog.addEntry ("The module \"PAUSE\" was successfully included.");Have fun with it.
cheers,
Jerry