views:

25

answers:

2

I have a flash file that I want to embed on a webpage, however, I want it to load when the user clicks on it (which will run the preloader) - (like clicking play on a youtube video)

It's one flash file that loads in XML data and is graphically heavy.

I'm not sure if the only way to do it is to load the flash file through another swf, i.e., flash container -> click flash container to load flash file with preloader.

Any suggestions?

A: 

You could add an additional frame before the already existing frames inside your movie and keep it at that position using:

stop();

Then, add a play button on your stage with a similar following action:

on (release) {
    gotoAndPlay("your_loader");
}

alt text

I uploaded a demo project to try it out.

jdecuyper
That doesn't work, that tells the stops the timeline from playing, not the data being loaded. Try that out with the bandwidth profiler and you'll see
decimal
The code located at frame 5 (on my image) will only get executed once the timeline hits the "loader" frame. How are you loading your XML data?
jdecuyper
decimal
I updated my answer with a small project to try out.
jdecuyper
I tried it out, your example doesn't work. If you drag in a large image past the 2nd frame you'll notice the bandwidth profiler shows immediate load.
decimal
My example was about dynamically loading your images/swf at frame "loader" and avoid immediate loading. If you drag an image to the scenario it will indeed get loaded immediately.
jdecuyper
A: 

My first impulse would be to use an image or explicitly-sized DOM element as a placeholder and some Javascript to swap in the Flash applet on-click. That'd be guaranteed to solve your loading issue as well as deferring the overhead of starting the flash player. (Which would make users who think like me but don't know about FlashBlock happy)

With jQuery, it'd just be something like

$('#flash_placeholder').click(function() {
    $(this).replaceWith(flash_applet_markup);
});

...and on-hover behaviour with something like opacity animation is also trivial.

ssokolow
Sounds great, I'll give it a whirl!
decimal