Hi! I want to know how to make a preloader to a movie. i searched for flash preloader tutorials in several sites but they are all examples of preloading images. Just images, no movie. :?: Especially a whole page made of Flash that takes time to load. It surely needs a preloader so as not to make visitors get bored of waiting.
I hope somebody can help me with my long-time problem.

Thank you and more power!

Dani AI

Generated

Short practical answer for (building on ): a full-page SWF is loaded the same way as any external asset, but the usual mistake is putting too much on frame 1 so the "preloader" never gets a chance to show. Two reliable approaches: a small external preloader SWF that loads the main SWF, or a minimal timeline preloader in frame 1 that stops() and watches bytesLoaded/bytesTotal.

Example (AS3 external preloader — put this in the small SWF):

var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onError);
loader.load(new URLRequest("main.swf"));

function onProgress(e:ProgressEvent):void {
    if (e.bytesTotal > 0) {
        var pct:Number = e.bytesLoaded / e.bytesTotal;
        progressBar.scaleX = pct;
        percent_txt.text = Math.round(pct*100) + "%";
    }
}

function onComplete(e:Event):void {
    addChild(loader);
}

Example (AS2 MovieClipLoader timeline loader):

var mcl:MovieClipLoader = new MovieClipLoader();
var listener:Object = {};
listener.onLoadProgress = function(target_mc, loaded, total) {
    var pct = Math.round(loaded/total*100);
    progressBar._xscale = pct;
    percent_txt.text = pct + "%";
};
listener.onLoadComplete = function(target_mc) {
    // show the loaded content
};
mcl.addListener(listener);
mcl.loadClip("main.swf", this.createEmptyMovieClip("holder", this.getNextHighestDepth()));

Key gotchas:

  • Uncheck "Export in first frame" for library items (components, fonts, class-linked symbols). If large assets/classes are exported in frame 1 they inflate the SWF and defeat your preloader.
  • For embedded video, prefer loading the video file separately (NetStream/streaming) rather than embedding it in the main SWF.
  • Handle IO errors and the zero-bytesTotal case to avoid divide-by-zero.
  • Note: Flash Player reached end-of-life in 2020 and modern browsers no longer support it. For long-term projects consider converting to HTML5/video or testing legacy SWFs in a local projector or emulator.

For Adobe's official statement about Flash end-of-life see Adobe Flash Player end-of-life.

Recommended Answers

All 2 Replies

oops, i'm sorry not videos but movie/page. my bad. :$

im pretty sure flash handles .swf movies similiar to images. I cant say for sure as i havent used flash in time. but i have this link which could help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.