Actionscript, Old Articles - 2 years, 11 months ago - 2 Comments
Flash 8 - setTimeout
Yup, you heard it here first. In Flash 8 actionscript you can tell the player to call a function just once after a specified interval. This means that you dont have to use setInterval anymore to call a function just once. For example the following code calls the openWebsite function after 1 second (1000 milli-seconds) and passes it a url. The openWebsite function then opens that url in a new browser window.
-
function openWebsite(url:String)
-
{
-
getURL(url,'_blank')
-
}
-
website='http://www.flashguru.co.uk'
-
setTimeout(openWebsite,1000,website)
And of course you can use the following syntax aswell:
-
function openWebsite(url:String)
-
{
-
getURL(url,'_blank')
-
}
-
website='http://www.flashguru.co.uk'
-
setTimeout(this,'openWebsite',1000,website)
Yet another one of those small features that make our lifes as Flash Developers just that little bit easier
Note: That to use the setTimeout function in Actionscript 2 classes, you will need to use array notation to avoid compiler errors as this function was left out of the intrinsic class definition files:
-
//call the showPopup function once after a second (1000 ms)
-
_global['setTimeout'](this,'showPopup',1000);
2 Comments
Nick
mark mun
if you use setTimeout in a AS 2.0 class, you can also write it without the bracket : _global.setTimeout(this,’showPopup’, 1000)
Note: This is an old article!
Please be aware that the content of this article may no longer be accurate and the links contained within could be broken.
Update Notifications
You can add our RSS feed to your favorite feed reader or recieve an email when a new article is posted by entering your email address below.
FLASH EXPERTS
- Andre Michelle
- Aral Balkan
- Big Spaceship
- Chafic Kazoun
- Colin Moock
- Craig Swann
- Erik Natzke
- Grant Skinner
- Jesse Warden
- John Grden
- Keith Peters
- Lee Brimelow
- Lord Alex
- Mario Kingemann
- Matt Voermn
- Ralph Hauwert
- Richard Leggett
- Trevor McCauley
FLASH COMPONENTS
- AFComponents
- Components Network
- Extend Studio
- Flash Relief
- Flash Store
- Flashden
- Flashloaded
- Ghostwire
- Image Vue
- Jumpeye
- Page Flip Component
- Slideshowpro
FLASH VIDEO
- Akamai
- FFMPEG
- FlashComGuru
- Flashstreamworks
- FLV Player
- FLVMDI
- flvPlayerPro
- FLVTool2
- Influxis
- JW FLV Player
- Vital Stream
FLASH RESOURCES
- Actionscript.org
- Adobe Labs
- Developer Center
- Flash Interface
- Flash Player Statistics
- Flashkit
- Kirupa
- MDM Zinc
- OSFlash
- PaperVision3D
- SWXFormat
- Tweener
SPONSORS
More In Actionscript
- Adobe MAKE SOME NOISE
- Undocumented Actionscript 3
- BitmapData.loadBitmap gone in AS3
- Actionscript 3 - New Capabilities
- Flash 8 - setTimeout


Wow, a very nice undocumented feature
Any others I haven’t heard about?