To schedule jobs, I've found nothing better than using a Cron string, especially when you want to schedule repeating tasks. A Cron allows you to do complex scheduling like launch every weekday at 14h00, except in July and August. Check out this sample with a cron editor and a scheduler test (right-click and view source). The scheduler runs a cronjob in the Flash client and dispatches a CronTaskEvent at the exact time that a task needs to be executed. Also very handy is the Predictor class that allows you to predict the next occurrence of a repeating scheduled task. Oh well, check out the source code to see what it does
.
When you would use this Cron4AS package in combination with the Flex scheduling framework for visualization of the agenda, you can build a powerful scheduling tool to plan repeating tasks and to run actions in the Flash client according to schedule because the Scheduler class will send out notifications when to do what. Typically, digital signage solutions built in Flex might benefit from this code, or any type of application that needs the possibility to schedule the execution of tasks of any kind.
For usability, you should decide to make an easier interface than my "full option cron editor" to set the repeating options. Google Calendar might be a good source of inspiration to build your user interface for editing the recurrence pattern.
Please note that a cron only defines certain points in time (with no beginning and no end). You must add the properties lifetime (as a Date range) and duration to task descriptions in order to build a scheduler.
Cron4AS is based on Cron4J, the work of Carlo Pelliccia.


4 Comments
Just corrected a little bug in the Predictor class. When the Predictor needed to predict across years, it skipped the month January. This problem is solved now.
Congratulations for this lib! It will come very handy for my project
I have only 2 questions:
The example app that you provide allows to edit the job duration. What does that parameter do exactly? ‘Cause I read throughout the code and it appears to have no effect on the Scheduler…
The other question regards documentation – Do you have any (besides comments in the code)?
Again, thank you so much for providing this lib.
@Carolina: the job duration is merely a meta data field that enables to create (recurring) agenda items with a certain duration like in this proof-of-concept: http://www.novio.be/demo/flexcalendar/.
I never really took the time to document the code, as I used this code for one project only.
If you want more information, I’d suggest to look here: http://www.sauronsoftware.it/projects/cron4j/, this is the Java library where Cron4AS is based on.
I would like to download the source for this scheduler but the zip file (under view source) is no good! Where can I download it from?
5 Trackbacks
[...] every day, every week, every month, on weekdays or weekends, etc.), then I suggest you check out this post about Cron4AS which served as the very basis for the scheduler PoC. This entry was posted in Uncategorized. [...]
[...] interface components directly using the package (and I have a few ideas for more). Admitted, I’ve blogged about this before, but while working with the package to build a schedule editor, I have made some important [...]
[...] to David Coletta, because I really need a steady timer for Cron4AS (to simulate unix’ cron tab behavior in the Flash client). This entry was posted in Uncategorized. [...]
[...] the blog post about Cron4AS [...]
[...] pattern and to predict occurrences for a certain scheduling pattern. For more information, read this post (and the trackbacks). addthis_url = ‘http%3A%2F%2Fwww.novio.be%2Fblog%2F%3Fp%3D902′; addthis_title = [...]