Saturday, May 20, 2006

Custom Intervals -- Pause, Extend, Change

SWF Example:





Class Files:
Interval.as

Source FLA:
IntervalExample.zip

On IRC tonight someone asked if it was possible to pause, or even extend an interval for a certian ammount of time. I wrote this class to allow you to do just that with an interval created via it. You can pause, unpause, change the interval (in real time with compensation), and extend the time of the current iteration of the interval. A basic method rundown.



  • Constructor

    • $f : The function you wish to have the interval call.

    • $s : The scope that the function resides in.

    • $d : The interval time (in milliseconds).




  • add
    --Creates the interval.


  • remove
    --Removes the interval.


  • pause
    --Pauses the interval (see Note 1).


  • unpause
    --Unpauses the interval (see Note 1).


  • extend
    --Extends the current iteration of the interval by $time.

    • $time: The time (in milliseconds) to extend the current iteration of the interval by (see Note 1).




  • changeInterval
    --Changes the interval time permanently.

    • $time: The time (in milliseconds) to set the current and all further iterations to (See Note 1).





If you peep the example file it should be comprehensive enough to give you a good idea of how to use the class. Please comment with any suggestions or complaints.



Note 1: These methods don't reset the interval. It will continue the interval from the point of pausing, extending, or changing.

Thursday, May 18, 2006

Updated WatchManager

Updated Class:
WatchManager.as
Bug Fixes:
Arguments are now fixed and passed correctly.
You can use $obj (parentObj.child1.child2....childN) for nested objects instead of $scope. However, this doesn't change the rules for $scope, it needs to be the scope of the top most object.


SWF Example:




Source: .FLA File