views:

2920

answers:

4

Suppose I have a large .swf file. Say, it's 10MB. I don't want the browser to load the entire file until user clicks a button in frame 1.

I don't want to use external files. I just want Flash Player to download first 10KB, display frame 1 and then stop until user click the button.

Is it even possible?

A: 

I don't think that this is possible. You can make sure that the user cannot click the button in frame 1 before the whole movie has finished downloading by looking at the framesLoaded property of the movieclip I believe, but I don't think you can actually stop a clip from downloading in mid progress.

macke
+2  A: 

As far as I am aware there is no way to stop the Flash Player loading at specific points within the swf file.

Is there any particular reason you would like to avoid using external files? Because I would suggest a small 10KB preloader swf for this. Once the user clicks the button it then loads your main 10MB swf file using flash.net.URLLoader.

Shrill
I completely agree with Shrill.
macke
+1  A: 

The Flash Player treats SWF files as a streaming format. This means that the moment Flash Player has downloaded the contents of frame #1 it will process this frame by displaying what's on that frame and executing the code on that frame. Flash Player will in the meantime start downloading frame #2.

If you place a stop(); command on frame #1 then the playback will stop but Flash Player will keep downloading the rest of the frames. This way you can make a preloader. You stop playback on the first frame, create a onEnterFrame that will monitor how much of the SWF file has been loaded and once that is 100% continue playing.

The short answer to your question, no you can not stop Flash Player from downloading following frames, you do need to use an external SWF file for your purpose.

Luke
+2  A: 

It is not possible without using external files. To do this using external files just do what Shrill said

But the better question is why? If the first frame is 10kb, then the first frame will be ready to play as of the file being 10kb loaded.

You can just wait until the first frame is loaded, and play it (the rest will just be downloading invisibly in the background), then once the user clicks the button have it do one of two things: if everything else is already done by then, then continue, if not then monitor the rest of the loading process until it is, then continue :)

swf files are a streamable format, there's nothing wrong with taking advantage of it!

Bryan Grezeszak