New York Design & Development Forums

Go Back   New York Design & Development Forums > Knowledge Bank > Tutorials
Connect with Facebook

Notices

Reply
 
LinkBack Thread Tools
Old 04-08-2006, 06:32 AM   #1 (permalink)
Senior Member
Fanatic
 
Michael's Avatar
 
Join Date: Mar 2006
Age: 26
Posts: 253
Michael is a glorious beacon of lightMichael is a glorious beacon of light
Send a message via AIM to Michael Send a message via MSN to Michael Send a message via Yahoo to Michael Send a message via Skype™ to Michael
Default Interval Manager

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" );
}
This class will be found in the package,

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
Michael is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Old 04-10-2006, 04:28 AM   #2 (permalink)
Who among you?
Enthusiast
 
General's Avatar
 
Join Date: Mar 2003
Age: 30
Posts: 98
General is on a distinguished road
Default

It worked!
General is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Old 04-10-2006, 05:11 AM   #3 (permalink)
Senior Member
Fanatic
 
Michael's Avatar
 
Join Date: Mar 2006
Age: 26
Posts: 253
Michael is a glorious beacon of lightMichael is a glorious beacon of light
Send a message via AIM to Michael Send a message via MSN to Michael Send a message via Yahoo to Michael Send a message via Skype™ to Michael
Default

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
Michael is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Old 04-10-2006, 05:59 AM   #4 (permalink)
Who among you?
Enthusiast
 
General's Avatar
 
Join Date: Mar 2003
Age: 30
Posts: 98
General is on a distinguished road
Default

Thank you.
General is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Old 06-30-2011, 11:21 PM   #5 (permalink)
Senior Member
Fanatic
 
Join Date: Jun 2011
Posts: 403
desiuser is on a distinguished road
Default Re: Interval Manager

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.
desiuser is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Old 06-30-2011, 11:50 PM   #6 (permalink)
Senior Member
Fanatic
 
Join Date: Jun 2011
Posts: 403
desiuser is on a distinguished road
Default Re: Interval Manager

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)?
desiuser is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit! Stumble this Post!Google Bookmark this Post!Blink this Post!
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT -4. The time now is 09:42 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45