Category Archives: Timer

Creating custom timers by extending the Timer class

In a previous example, “Creating timers using the Timer class”, we saw how to create simple timers using the Timer class and listening for the timer and timerComplete events.

The following examples show how you can extend the Timer class to add methods and properties to the Timer object, which allow you to pass additional data to the event handlers.

Full code after the jump.

Continue reading Creating custom timers by extending the Timer class

Creating timers using the Timer class

In previous examples, we saw how to use the setInterval() and setTimeout() methods to create simple timers.

The following example shows how you can execute code at regular intervals using the Timer class. It also shows you how you can create timers that repeat continuously as well as timers which only execute a specific number of times.

Full code after the jump.

Continue reading Creating timers using the Timer class

Using the URLVariables and FileReference classes to pass data from Flex to a server-side script

We’ve already seen examples of using Flex to upload and download files (see “Uploading files in Flex using the FileReference class” and “Downloading files in Flex using the FileReference class”), but I’ve seen a lot of bugs/questions centering around the FileReference class lately so thought I’d try and do another example or two.

The following example shows how you can use a combination of the URLVariables, URLRequest, and FileReference classes to pass GET or POST variables to a server-side script while doing a file upload. In this example, we just happen to pass a simple text userID and the user’s Flash Player version, but it should be easy enough to modify the script slightly to pass more unique information to the server (such as a unique user token stored in a SharedObject or a browser cookie). I also added a crude little timer on the example to make it a bit classier.

Full code after the jump.

Continue reading Using the URLVariables and FileReference classes to pass data from Flex to a server-side script

Disabling a Button control for a fixed number of seconds

I was installing a couple of Firefox plug-ins today and noticed the handy delay on a dialog window, which basically forces you to stare at the dialog for 2-3 seconds before you can press “OK”. Although it can be mildly annoying at times, I can see a lot of places where it would be nice to do that in a Flex application, even if it just helps to throttle user submissions (for example, a user couldn’t submit a feedback form for 3-5 seconds after the form was shown).

At any rate, I quickly threw this code together which creates a simple Flex Button control and disables it for 3 seconds. Naturally, I’m sure the code could be improved, or even possibly simplified if you didn’t want/need to update the button label with the counter, but hey…

Full code after the jump.

Continue reading Disabling a Button control for a fixed number of seconds