the following code is actionscript 2, but i need it in actionscript 3.
a few things stick out as not going to work, of course the _global and instanceof calls.
replacing the instanceof call with “is” fior example
if ( connection is MovieClip )
instead of
if ( connection instanceof MovieClip )
what i cant figure out is what to replace the *_global *call with. right now i just took out the _global and the errors i receive are
1137: Incorrect number of arguments. Expected no more than 5.
1120: Access of undefined property MovieClip.
any ideas??
class com.oop.managers.IntervalManager
{
static private var __listeners:Object = {}; // Will hold references to all objects that have called setInterval
static private var __intervalID:Number = 0; // Will increment for any non-Movieclip instance calling setInterval
function IntervalManager() {}; // Constructor
/**
* Overloaded setInterval function ( now requires 5 arguments instead of 3 )
*
* @param connection Indicates how the interval call will be stored (this will be a reference to a MC instance or to another class instance)
* @param intName String name for the interval
* @param path Path to the function to be called
* @param func Name of function to be called on path specified
* @param time Milliseconds between each call
*/
static public function setInterval( connection:Object, intName:String, path:Object, func:String, time:Number ):Void
{
clearInterval( connection, intName ); // makes it uncessary to call clearInterval before setInterval from now on
if ( connection instanceof MovieClip ) // saves a reference into __listeners if object is an MC instance
{
if ( __listeners[connection] == undefined )
{
__listeners[connection] = {};
}
// store reference of setInterval call into the __listeners Object ( to prevent orphaned intervals )
__listeners[connection][intName] = _global.setInterval( path, func, time, arguments[5], arguments[6], arguments[7], arguments[8], arguments[9], arguments[10] );
}
else // if its not an MC, this generates an ID for the Object.
{
if ( connection.intervalID == undefined )
{
connection.intervalID = "int" + ( __intervalID++ );
}
__listeners[connection.intervalID] = {};
__listeners[connection.intervalID][intName] = _global.setInterval ( path, func, time, arguments[5], arguments[6], arguments[7], arguments[8], arguments[9], arguments[10] );
}
}
static public function clearInterval( connection:Object, intName:String ):Void
{
if ( connection instanceof MovieClip )
{
_global.clearInterval ( __listeners[connection][intName] );
}
else
{
_global.clearInterval ( __listeners[connection.intervalID][intName] );
}
}
}