Time delay loading for swf files and images

Date: 26th March 2008 at 11:54 pm | Filed under: actionscript, development, flash, scripts | Author: Sam Burdge

Q. How can I make an image or swf file load after a specified number of seconds?

A. Use the simple but effective flash_timer.swf file by Sam Burdge. Whoopeee!

Ever wanted a particular Flash movie or image to load up / start playing after the rest of your page has loaded, or after a set amount of time? This tutorial, and the support files provided with it will make it very easy indeed. The flash_timer.swf file will load a swf or image into your page after a number of seconds that you specify.

Example:

Check out this basic example to see a swf (called test.swf) load after a 10 second delay: Example 1
You can view the source code of the example to see how it works.

Usage:

  1. Download the source files using the link below, and unzip the archive.
  2. Embed the swf file 'flash_timer.swf' into your webpage. In my example I have used the swfObject method to embed the file, but you can use whichever method you prefer. For more information about this you can check this useful tutorial by Jeroen Wijering.
  3. Set the height, width & background colour of the swf according to those of the file you want to load in.
  4. Pass the two variables that the file requires to work: myswf – the file that will be loaded & mysecs – the number of seconds delay before the file is loaded. You can pass the variables in the url string, for example:

flash_timer.swf?myswf=my_movie.swf&mysecs=5

(This will load the movie 'my_movie.swf' after a 5 second delay.)

You can also pass the variables as flashvars, for example:

flashvars="myswf=example.jpg&mysecs=10"

(This will load the image 'example.jpg' after a 10 second delay.)

I hope you find this useful, if you do or if you have any questions, please feel free to leave a comment on this page (no emails please, I won't reply unless you are offering me hard cash!!). The flash_timer.swf file is only 1kb, so it will not effect the overall loading time of your page, it can be embedded at any height/width dimensions and works from flash player 7 upwards.

Download Source:

The download contains the all important flash_timer.swf plus a working example (index.html). The size of the zip is 6kb. Enjoy!!


14 Responses to “Time delay loading for swf files and images”

  • Comment by Bob Stone
    Date: May 12th, 2008 at 1:32 pm

    Excellent, excellent, excellent! spectacular! stupendous!

    Was exactly what I was looking for.
    And does exactly what you said it would do!
    Can’t say that about many other things I’ve downloaded - including stuff I’ve paid for!

    Good show!

  • Comment by Wayne Moran
    Date: June 21st, 2008 at 1:40 am

    Great tool - well done. One issue however: how can I prevent my video from repeating / looping continuiously. I have tried setting &loop=false as part of passing the swf filename and I have set it in the calling code as well but it ignores them. See the code below:

  • Comment by Nathan
    Date: September 10th, 2008 at 10:14 pm

    I have the same problem as Wayne Moran. I would like the flash to run only once, as the constant repeating would detract from the sight and prevent the point of the flash from being made.

  • Comment by dave.com
    Date: September 19th, 2008 at 5:57 pm

    Works perfectly… Amazingly simple…see http://www.hotmix.org

  • Comment by Bhaskar
    Date: November 28th, 2008 at 4:39 am

    Excellent work !.
    Its working fine. But I have placed my own swf insted of yours (test.swf). That is not working. Can you suggest a solution.

  • Comment by delicious
    Date: April 27th, 2009 at 12:03 am

    So, if I understood this:
    I have a webpage, I want it to download the page files that are not flash files first, so clients be able of start reading stuff and see some light weight images, so once the files be downloaded say 5 secs, as it is rather light stuff, then I would like the flash file to start being downloaded, because clients will be busy reading and watching other stuff while the flash file downloads, is that correct????????

  • Comment by George
    Date: August 20th, 2009 at 8:29 am

    Great tool.
    @ Wayne Moran and Nathan: This is not a problem of the swf file from Sam, it must be a problem of your swf, which loops.
    Bye
    George

  • Comment by Kyle
    Date: September 4th, 2009 at 1:53 pm

    I cannot get this to work on a LAMP server. Any ideas?

  • Comment by istochath
    Date: September 29th, 2009 at 8:28 pm

    I am a total noob at times, more an artist than a webmaster. I’m trying to plug this in with no success. Could I get a hand with this, I’m plunking it in to a div cause I have a heavily layerd page. Thanks.

  • Comment by lushmind
    Date: December 23rd, 2009 at 2:26 am

    what is the function of the “8″ in the string? it seems to be a variable, but for what?

    thanks.

  • Comment by clarp
    Date: October 5th, 2010 at 12:07 pm

    Hi Sam, Sorry but I’m being very dumb… I follow the logic but can’t seem to apply it to my situation!
    I’m using a javascript call on a swf music player.

    Happy to send a donation to a fellow Brit to get it working ;-)

    Thanks,

    Peter

    var options = {};
    options.mediaPath = “images/stories/audio/lifestyle_mono.mp3″;
    options.firstColor = “b7b7b7″;
    options.backColor = “3E2D23″;
    options.strokeColor = “3E2D23″;
    options.autoPlay = “true”;
    var params = {};
    params.allowScriptAccess = “always”;
    swfobject.embedSWF(”images/stories/audio/LWMusicPlayer.swf”, “player-holder”, “45″, “21″, “9.0.0″,false, options, {}, {});

  • Comment by Diana
    Date: October 27th, 2010 at 8:36 pm

    Fabulous! You rock man, quick question, is there a way i can have a background image displayed until it starts showing the movie?

  • Comment by Jennifer
    Date: December 22nd, 2010 at 5:16 pm

    I am trying to implement this on my site and everything works great except there is a giant black box in the space where my movie will be once it loads. Is there a way to have an image there instead, that will then be replaced once the movie loads? How would I do this…

    Thanks! <3

  • Comment by dionys
    Date: March 11th, 2011 at 7:13 pm

    I have links on my flash file (set with .xml file). They don’t work with flash_timer.swf. Do you have any ideas why?

Leave a Comment

Nice / Monaco 2008

Date: 10th March 2008 at 11:25 pm | Filed under: gallery | Author: Sam Burdge

 

SimpleViewer requires Macromedia Flash. Get Macromedia Flash.
This is a WPSimpleViewerGallery

 

Leave a Comment

Classic Film & Animation - Jan Svankmajer - Food

Date: 10th March 2008 at 10:35 pm | Filed under: video | Author: Sam Burdge

This is one of my all time favourite animated films, Food by Jan Svankmajer. Here it is split into three parts - breakfast, lunch and dinner. Very surreal!

BREAKFAST


LUNCH


DINNER


About Jan Svankmajer: Wikipedia, IMDB

Leave a Comment

Image mouseovers without javascript - CSS & Sprites

Date: 3rd March 2008 at 1:27 am | Filed under: development, scripts | Author: Sam Burdge

This article is an extension / improvement upon another article I published on my site previously: {{post id="simple-javascript-for-image-mouseovers" text="Simple Javascript for Image Mouseovers"}}. As I am always looking for improved methods, I was discussing the pitfalls of the javascript method with a friend (and occasional comment writer / contributor to my site) who pointed me in the direction of CSS and image sprites. This lead me to research the topic further, and I found two articles in particular which were incredibly useful:

Read on…

5 Responses to “Image mouseovers without javascript - CSS & Sprites”

  • Comment by Jonn
    Date: April 29th, 2008 at 1:15 pm

    Very nice article. Thanks.

  • Comment by hot girls publisher
    Date: July 13th, 2008 at 7:20 am

    I used this article in the making of this website! Thanks! http://www.girlsbeinghot.com

  • Comment by Ray
    Date: February 18th, 2009 at 4:36 pm

    Super-informative site! I am loving it!! Will come back again - taking you feeds also, Thanks.

  • Comment by Иван Евсеев
    Date: June 13th, 2009 at 4:14 am

    Замечательно написано, но как говорится, для полноты информации нужно минимум хотя бы три источника :)

  • Comment by Datsu
    Date: July 31st, 2009 at 8:20 pm

    This was extremely helpful; exactly what I was looking for and simple to implement. Thank you!

Leave a Comment