![]() |
| | #1 (permalink) |
| Senior Member Fanatic | Another little useful class I decided I'd give to you guys since it's going to be a bit before the kit is out. This is used to manage intervals. It may not seem like a big deal, but it has honestly saved me so much time and grief. It gives you one location for setting and clearing intervals, and even allows you to set a timeout function. Here is the class, IntervalManager.as Code: /**
* Flash's interval management is horrible. Here we provide a way
* of setting and clearing intervals, in one location.
*
* @author Michael Avila
* @version 1.0.0
*/
class IntervalManager
{
// stores the interval ID's in a dictionary, so that you can name them
private static var intervalIDs : Object = new Object();
/**
* Sets an interval, storing it's reference in this IntervalManager. If there is already an interval associated with the
* name that you provide (meaning an interval that was created with but not cleared with the IntervalManager), the IntervalManager
* will clear the interval and set the interval you provide in it's place.
*
* @param The name you are assigning the interval, note that this is how you will be deleting it
* @param The path to the function that will be called by the setInterval
* @param The name of the function as a string
* @param The interval that this function will be called on
* @param The args that will be passed to the interval. The arguments are passed as an array, so be sure
* to have your function compensate for that.
*/
public static function setInterval( name:String, path:Object, functionName:String, interval:Number, args:Array ) : Void
{
if ( IntervalManager.intervalIDs[name] != undefined)
{
IntervalManager.clearInterval( name );
}
IntervalManager.intervalIDs[name] = _global.setInterval(path, functionName, interval, args);
}
/**
* Sets a function to be called at "interval" seconds after the timeout is set. If there is already a timeout associated with
* the name that you provide (meaning an interval that was created with but not cleared with the IntervalManager), the IntervalManager
* will clear the old timeout and set the new timeout you provide in it's place.
*
* @param The name you are assigning the timeout
* @param The path to the function that will be called by the setTimeout
* @param The name of the function as a string
* @param The interval that this function will be called on
* @param The args that will be passed to the timeout. The arguments are passed as an array, so be sure
* to have your function compensate for that.
*/
public static function setTimeout( name:String, path:Object, functionName:String, interval:Number, args:Array ) : Void
{
if ( IntervalManager.intervalIDs[name] != undefined)
{
IntervalManager.clearInterval( name );
}
IntervalManager.intervalIDs[name] = _global.setTimeout(path, functionName, interval, args);
}
/**
* Clears the interval with the name you provide.
*
* @param The name of the interval you'd like to clear.
*/
public static function clearInterval( name:String ) : Void
{
_global.clearInterval( IntervalManager.intervalIDs[name] );
delete IntervalManager.intervalIDs[name];
}
}
[/php]
The code is simple... no need to worry about it.
Here is the code in the fla:
[php]
IntervalManager.setInterval("hello", this, "sayHello", 1000, ["Michael"]);
IntervalManager.setTimeout("helloOnce", this, "sayHelloOnce", 1000);
function sayHello(args:Array) : Void
{
trace("Hello, " + args[0]);
}
function sayHelloOnce() : Void
{
trace( "Hello from the TimeOut" );
}
function onMouseDown()
{
IntervalManager.clearInterval( "hello" );
}
createage.managers in the Dev Kit. The documentation for the dev kit can be found here... www.createage.com/CreateageLib Take Care. _Michael
__________________ Actionscript Developer :P ...Dope... http://www.createage.com http://www.myspace.com/michaelxxoa <--- yeah I'm a nooob, so what |
| | |
| | #3 (permalink) |
| Senior Member Fanatic | Thanks, General_Mayhem :P If you have any questions feel free to ask. Take Care. _Michael
__________________ Actionscript Developer :P ...Dope... http://www.createage.com http://www.myspace.com/michaelxxoa <--- yeah I'm a nooob, so what |
| | |
| | #5 (permalink) |
| Senior Member Fanatic Join Date: Jun 2011
Posts: 403
![]() | hm ..�There is pretty much nothing that it is not & are many free apps that make a lot of fun.�I would think, if I need 3G, or not?�- Have unfortunately a ipad without 3g 32gb but with - rather have a 16gb to buy 3g ...�tja ..� how to copy dvd mac I agree they need to do this for the americans that are stupid. Kinda like caution your coffee is hot� no duh its hot its coffee. And fyi its for all phones not just iphone my android follows me and I knew that before all this went down. |
| | |
| | #6 (permalink) |
| Senior Member Fanatic Join Date: Jun 2011
Posts: 403
![]() | I need my precious iPhone 3G from damages and not the cheapo silicon case to protect it cut. I love to plan my iPhone 3G and keep my family safe and give him a reminder of the era of innovation. Congratulations to Rene for the writing of the 10,000 post for TiPb. And congrats to the blog, take their authors, commentators and moderators of this wonderful community. And finally, a message of congratulations to Apple. Without their innovative thinking, we would not have the phone that revolutionized the mobile industry forever. (A bit cheesy, but you know what I mean.) Pssst ... white. ;) avi to mp4 converter mac According to Verizon's CEO, they were not really approached only for the iPhone - Apple GSM liked better from the getgo (Google it)? |
| | |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| |