I've been working with Spring 3.0 a good bit lately. One of the things that I've really enjoyed working with is the new ability to create rudimentary scheduled tasks with annotations. This got me to thinking, why can't we do the same thing in Swiz? We have the Timer class. Why not use the same type of methodology to create a custom metatdata processor to handle the execution of scheduled tasks in Flex with Swiz? I heard Ryan Campbell speaking about custom metadata processors at Flash Camp Seattle, and decided to take a look at his examples of the URLMapping processor as a guide. What I came up with is this, a metadata tag that will let you run a method at a set interval, for a defined number of runs (or unlimited if undefined). You make use of the tag like this:
It's really that simple.
There are two properties that you need to be concerned with: delay and repeatCount. delay is the default property and is the interval which to run the Timer, in milliseconds. repeatCount is the number of times to repeat the Timer, the default is 0, which means repeat as long as the application is running.
Resources:
SWC Download
Example Download (Requires SWC and Swiz Framework)
Swiz Timer on GitHub























2 responses so far ↓
1 madsmao // Jul 21, 2010 at 9:49 AM
2 Andrew Powell // Jul 21, 2010 at 10:04 AM
Leave a Comment