Preloading? kglad?

I've had lots of issues using the method of creating a preloader swf for my websites. An example is the other thread I have going on here. How can I self preload my background.swf (the swf that contains the navigation and other code). Everything I've tried doesn't work. It always preloads everything and then my preloader shows up at 80%.

My assets in frame 1 are down to 12 kb's. I have the st
andard preloaderSWF loading with the little dots. However, the progress code doesn't work. There for I cannot seem
to display a percent to the user, just the dots animation. How do I get the preloaderSWF to show percentage when the per
centage code in on the main.swf?
Main.swf
stop();
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.addEventListener(Event.COMPLETE, onComplete);
function onLoading(evt:ProgressEvent):void {
var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
//percent_txt.text = (loaded*100).toFixed(0) + "%";
trace(loaded);
function onComplete(event: Event):void {
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS, onLoading);
this.loaderInfo.removeEventListener(Event.COMPLETE, onComplete);
gotoAndStop(2);
***** default preloader SWF
// avoid accessing the stage if it is not your immediate parent
// to prevent security sandbox errors with content loaded across domains
var myStageWidth:int, myStageHeight:int;
var mainTimeline:DisplayObjectContainer = this;
try {
// go up to the Loader
if (mainTimeline.parent != null) {
  mainTimeline = mainTimeline.parent;
// go up to the parent of the Loader
if (mainTimeline.parent != null) {
  mainTimeline = mainTimeline.parent;
if (mainTimeline is Stage) {
  myStageWidth = stage.stageWidth;
  myStageHeight = stage.stageHeight;
} else {
  myStageWidth = mainTimeline.loaderInfo.width;
  myStageHeight = mainTimeline.loaderInfo.height;
} catch (se:SecurityError) {
if (mainTimeline != null) {
  myStageWidth = mainTimeline.loaderInfo.width;
  myStageHeight = mainTimeline.loaderInfo.height;
// center animation in the middle of the stage
anim_mc.x = (myStageWidth) / 2 - (anim_mc.width / 2);
anim_mc.y = (myStageHeight) / 2 - (anim_mc.height / 2);
function handleRSLError(callback:Function, numComplete:int, numFailed:int, failedURLs:Array):void {
trace("rsl error!");
trace("numComplete " + numComplete);
trace("numFailed " + numComplete);
trace("numComplete " + numComplete);
trace("failedURLs:");
for (var i:int = 0; i < failedURLs.length; i++) {
  trace("  " + failedURLs[i]);
callback();

Similar Messages

  • Status bar for multiple preloaded levels (kglad are you there?)

    OK, ive been building a site for about a month now and slowly piecing it together- so far ive managed to get all my various different levels loading and unloading the way i want them to, but now id like a little status bar to load on screen as my multiple levels are loaded in the background.
    The way ive been accomplishing this without the load bar is like so:
    on first frame of main movie
    loadMovieNum("dl_web.swf", 3);
    loadMovieNum("dl_illustration.swf", 4);
    loadMovieNum("dl_retouching.swf", 5);
    (the first frame of each of those movies has a stop function on it)
    And i have buttons on the main movie that make each of those levels visible and play.
    NOW, ive just created a movie clip ive named "bar" which is a thin rectangle, and i would like to have that movie clip load lengthways as my multiple levels are loaded in the background. So, my question is how do i accomplish this? I've looked all over and it seems like all the good preload tutorials are loading into movieclips whereas i am loading into levels.
    Right now my site is technically working, but there will be pauses for people with slower internet connections and i need my bar graphic to pop up so they dont think they are dealing with a broken site....

    that code should be in a frame (like 1), that plays once.  the playhead should not return to that frame.
    oops, we also need:
    loadMovieNum("test.swf", 3);
    loadMovieNum("dl_illustration.swf",  4);
    loadMovieNum("dl_retouching.swf", 5);
    preloadI=setInterval(preloadF,200);
    function  preloadF(){
    var  bl:Number=0;
    var  bt:Number=0;
    if(_level3.getBytesTotal()>0){
    bl+=_level3.getBytesLoaded();
    bt+=_level3.getBytesTotal();
    if(_level4.getBytesTotal()>0){
    bl+=_level4.getBytesLoaded();
    bt+=_level4.getBytesTotal();
    if(_level5.getBytesTotal()>0){
    bl+=_level5.getBytesLoaded();
    bt+=_level5.getBytesTotal();
    if(bt>0){
    bar._xscale  = 100*bl/bt;  //<- adjust this to suit your needs.
    if(bl>0&&bl>=bt&&_level3.getBytesLoaded()>0&&_level4.getBytesLoaded()>0&&_level5.getBytesL oaded()>0){
    clearInterval(preloadI);

  • Preloader for xml image gallery

    Hi,
    I am a little stuck as to where to begin; I have created a
    photo gallery and now need to add some preloader capability to it.
    The images are brought in via XMLList etc... What I have in mind, I
    would like to display a preloader untill all the images are ready
    for viewing - not wanting to preload individual images one by one
    I also have a document class within the gallery swf file, I
    beleive that this may cause conflicts with attaching a preloader to
    frame 1 - I have tried preloading the gallery swf file via a
    preloader.swf; the end result still leaves me with having to
    provide a preloader within the gallery swf.
    Can anyone point me to any good examples, for me to get on
    with it. Any help would be really appreciated folks ;)
    Kind Regards,
    Boxing Boom

    Hi Kglad,
    Thank you for your response: my images are loading sequentially via the following code segment;
    //initialize the loader object
       loader=new Loader();
       //add an onInit event to the contentLoadedInfo
       loader.contentLoaderInfo.addEventListener(Event.INIT, onImageLoaded);
       //create the fake holder
       fakeHolder=new Sprite();
       //and add to it the loader
       fakeHolder.addChild(loader);
       //no need to add it to the stage
       //force the resizeHandler to be called
       resizeHandler(null);
       //Load the XML file
       xmlLoader=new URLLoader();
       //assign the Complete loading event
       xmlLoader.addEventListener(Event.COMPLETE,parseXML);
       //load the file
       xmlLoader.load(new URLRequest("data.xml"));
       //initialize the url request
       urlRequest=new URLRequest();
    What I would like to do now is preload these,
    Would the code to acheive this be:
    xmlLoader.addEventListener(ProgressEvent.PROGRESS ,onProgress);
    private function onProgress(pe:ProgressEvent):void
       // this bit is what I do not understand; i.e. your x/n + bl/(bt*n) fraction example
    Any further help on this on, would be really appreciated Kglad.
    Kind Regards,
    Boxing Boom

  • The external preloader doesn't wait?

    Hello! I have a new dilemma concerning external preloaders.
    Now I found out that sometimes external preloaders don't wait to load the entire swf file before this last one runs.
    I read a few tutorials, specifically this: http://sierakowski.eu/list-of-tips/45--two-ways-of-preloading-in-actionscript-3.html.
    I understood the concept and I applied both explained methods, but still couldn't find a solution: the swf file runs before the preloader finishes to load.
    Can anybody help me?
    This is my code (useless) so far:
    import flash.display.MovieClip;
    var myLoadedMovieClip:MovieClip;
    var contentLoader:Loader;
    loadContent("Index11.swf");
    function loadContent(url:String):void
        contentLoader = new Loader();
        contentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
        contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded);
        contentLoader.load(new URLRequest(url));
    function contentLoaded(evt:Event):void
        myLoadedMovieClip = MovieClip(contentLoader.content);
        myLoadedMovieClip.play();
        removeChild(progressbar);
        addChild(myLoadedMovieClip);
    function loading(evt:ProgressEvent):void
        var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
        setBarProgress(loaded);
    function setBarProgress(value:Number)
        progressbar.bar.scaleX = value;
        contentLoader.visible = true;

    Thank you Kglad!
    Thanks to your questions, I realised there wasn't a problem with the code you gave me at all.
    It was MY problem. I got confused and I should be more systematic and organised with my files.
    Now everything works fine.
    I leave the code properly written, in case anyone needs to see it:
    from the External preloader:
    import flash.display.MovieClip;
    var myLoadedMovieClip:MovieClip;
    var contentLoader:Loader;
    loadContent("Index11.swf");
    function loadContent(url:String):void
        trace("start load");
        contentLoader = new Loader();
        contentLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loading);
        contentLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, contentLoaded);
        contentLoader.load(new URLRequest(url));
    function contentLoaded(evt:Event):void
        trace("loaded");
        myLoadedMovieClip = MovieClip(contentLoader.content);
        myLoadedMovieClip.play();
        removeChild(progressbar);
        addChild(myLoadedMovieClip);
    function loading(evt:ProgressEvent):void
        var loaded:Number = evt.bytesLoaded / evt.bytesTotal;
        setBarProgress(loaded);
    function setBarProgress(value:Number)
        progressbar.bar.scaleX = value;
        contentLoader.visible = true;
    And in the swf file:
    first frame (with blank keyframes in the timelines):
    stop();
    trace("frame",1);
    second frame:
    trace("frame",2);
    my url is: http://gabrielates.com/
    Thanks again!

  • Preloader  #1009 error

    Halo. I've been trying to load external swf  ("index.swf") with the following code in AS3:
    //it's a simple preloader with one dynamic text field: "percent"
    //the "index.swf" is suppose to stop at 689 frame after being loaded (this part works fine)
    stop();
    import flash.display.*;
    import flash.net.URLRequest;
    import flash.events.Event;
    var l:Loader = new Loader();
    l.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgress);
    l.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
    l.load(new URLRequest("index.swf"));
    function onProgress(event:ProgressEvent):void{
       var perc:Number = event.bytesLoaded / event.bytesTotal;
       percent.text = Math.ceil(perc*100).toString();
    function onComplete(event:Event):void{
       var container:MovieClip = MovieClip(l.content);
       removeChild(percent);
       percent = null;
       addChild(container);
       container.gotoAndStop(689);
    Of course I receive the #1009 error : Cannot access a property or method of a null object reference. I guess it is some "stage issue" but I'm not familiar enought with AS3 to avoid the problem by my own.
    Could you please help me with the code.

    You were right. My idea about "stage issue" also was confirmed.
    The problem was in part of the code on the first frame of the "index.swf" (file that I was trying to load):
    stage.align="T";
    I think that this part of the code is being executed before the "index.swf" is loaded.
    Thanks for replies "kglad" and "Ned Murphy"
    Regards

  • Preloader and moviecliploader class

    Hello
    Firstly thanks to kglad for some advice yesterday. More needed
    I am using FlashMX 2004 Professional.
    I have been having problems with my preloader which i have placed as a movieclip at the start of the pertinent scenes where it is needed. The problem has been one of file size in frame one -  a common problem I beieve. This causes the preloader script to malfunction and come in late and show just 100% loaded of the preloader animation - again a common problem I am reading. SO it seems clear having designed the whole website using LoadMovie Number that the movieClipLoaderClass would be the solution to getting my Preloader to work. Hmm..
    So can people tell me that if I now create a seperate scene for the preloader and have it listen for any downloading swf to activate using the moviecliploader class will this work ok in tandem with how I have connected all the other scenes using the loadmovienumber? Just need to now before I start trying that out. My hope is that the Preloader will then overcome the file size issue of the first frame because and it will not have to load itself every time afresh.
    Hope this makes sense, I am fairly inexperienced here...
    Cheers
    Pete

    I know everything about the file, I know that the sound starts on the first frame and also I know it ends on the last frame. If the sound data are on the main timeline, the sound could be streamed and you don't have to load it fully to start playback. The question is the same, how much I need to load to start the sound.
    I think it's not very clear why I need this. Imagine:
    - you need to play the external SWF file
    - you start to load it via the MovieClipLoader class
    - onLoadInit you stop the movie and wait for the load
    - check, if you can run the movie - based on bytes and/or frames you can determine, you preloaded enough, so the movie won't be stopped and you don't have to load more to continue
    - but, when you run the movie, the animation starts, just the sound doesn't, because more of it needs to be loaded.
    - then after short time the sound start to play and since it's streamed and on the timeline, it's sync with the animation
    So, in this scenario a few seconds of the sound are skipped / missing in playback. Of course, it could happen that the sound runs fine, because the SWF content could be different. I can't say 20% of the file size is audio and the rest is the animation.
    I wanted fully flash solution, but it seems I'll have to find it in combination with Java, because it seems there is no way to distinguish between audio and other data in the Flash movie in AS.
    Anyway, thank you for your help.

  • Preloader browser/server problem

    Hello.
    I recently completed a Flash project for a client of mine. On all the swf movies, I have put a preloader script that downloads the whole movie before it plays. Off of my IP (1and1 internet) all the movies load flawlessly in all the browsers I have, IE, FireFox, and Chrome. Here is the link:
    http://www.sdmdesign.com/Outside.html
    You can click on the houses or the tabs to go to different pages.
    I am not doing the actual Html or page creation and design. The person who is doing the html (they are using a cms system) is having a big problem with the movies loading from there IP. They only load in Fire Fox and no other browser. Here is their link:
    http://www.souldecisions.org/
    Does any one know why this might be happening?
    Could their IP servers not have the correct scripts on them for preloading swf movies?
    The webmaster insists it is a cross browser problem with the preloading script but I just don't believe that because the movies work in all browers from my IP.
    Any help or suggestions from this fine forum would be much appreciated. Thanks.
    -Shawn

    Hi kglad.
    Thanks for responding. Did the page from my server work for you?
    Here is the code from one of my html pages. Could you tell me what is
    incorrect? Thanks.
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!--
    body,td,th
    body {
    background-color: #000;
    -->
    <!>>
    <!<![endif]>
    Content on this page requires a newer version of Adobe Flash
    Player.
    !http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif|height=33|alt=Ge t Adobe Flash player|width=112|src=http://www.adobe.com/images/shared/download_buttons/get_flash_player .gif!
    <!>>
    </object>
    <!<![endif]>
    <!>>
    <!<![endif]>
    Content on this page requires a newer version of Adobe Flash
    Player.
    !http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif|height=33|alt=Ge t Adobe Flash player|width=112|src=http://www.adobe.com/images/shared/download_buttons/get_flash_player .gif!
    <!>>
    </object>
    <!<![endif]>
    !barbottom.jpg|height=84|width=1024|src=barbottom.jpg!
    </html

  • Today is the day the preloading will work! Help...

    I've tried and tried to find different ways to make the preloading work correctly but there is always something that doesn't seem to work with each way. Could someone dumb it down for me and help me understand how to make this work. I've read everything on the safeloader and at this link:
    http://www.stevensacks.net/2010/05/28/flash-cs5-tlf-engine-causes-errors-with-loaded-swfs/
    I've also browsed all blogs and adobe tech notes and just had no luck getting a way that always worked. Here is what I'd like to do:
    Create a preloader swf that contained a movie clip to display the percent.
    Allow the preloader swf to call functions inside of the loaded swf. (this is for stage resizing, usually)
    Be able to use the tlf textengine in my loaded swf's.
    Keep my reference to the stage or pass it from the preloader swf to the loaded swf.
    Every way I've tried seems to lose at least one of these items. Right now I have a file that uses the tlf textfield and a stage reference. It works fine as a standalone swf but it needs a preloader. In the as 3 settings the tlf is merged into the code. The extra size isn't that big of a deal, for now. However, I would love to not do that and point the preloader away from adobe's stock preloader to my own in the as 3 settings. However, I can never get it to work correctly.
    Can anyone point me in the right direction? Thanks!

    Kglad, I created a system
    that works. I will post it here so others can use it if needed.
    Outline: I'm using a custom preloader.swf to load another swf file. The loaded swf file contains a document class and the tlf textfield. I am able to load this correctly, track the percent loaded, pass the stage reference, use the tlf textfield and use the stage resize functions to dispatch listeners for sites that are 100% of the browser.
    THE PRELOADER SWF
    This file simply contains the preloader movieclip in the library and code in frame 1. I guess a doc class would work here but I have not tested. The AS 3.0 settting are the default settings for player 10.
    Code:
    //======================================================================================== =================================================
    //     import classes
    //======================================================================================== =================================================
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.events.Event;
    import flash.filters.BevelFilter;
    import flash.display.MovieClip;
    import flash.display.Loader;
    //======================================================================================== =================================================
    //     set stage alignment
    //======================================================================================== =================================================
    stage.scaleMode = StageScaleMode.NO_SCALE;
    stage.align = StageAlign.TOP_LEFT;
    stage.addEventListener(Event.ACTIVATE, activateHandler);
    stage.addEventListener(Event.RESIZE, resizeHandler);
    //======================================================================================== =================================================
    //   variables
    //======================================================================================== =================================================
    var pre_loader:Preloader;
    var this_page:String = "sbBackground.swf";
    var load_bar_width:Number = 150; // make this the width of your image
    //======================================================================================== =================================================
    //    variables
    //======================================================================================== =================================================
    function activateHandler(event:Event):void {
    trace("here");
    //======================================================================================== =================================================
    //    variables
    //======================================================================================== =================================================
    function resizeHandler(event:Event):void {
    trace("resizeHandler: " + event);
    trace("stageWidth: " + stage.stageWidth + " stageHeight: " + stage.stageHeight);
    //======================================================================================== =================================================
    //    variables
    //======================================================================================== =================================================
    var background_ldr:Loader;
    var background_mc:MovieClip;
    var background_holder:MovieClip = new MovieClip();
    addChild(background_holder);
    //======================================================================================== =================================================
    //    init site
    //======================================================================================== =================================================
    function init():void{
    // show preloader
    pre_loader = new Preloader();
    addChild(pre_loader);
    pre_loader.x = Math.round(stage.stageWidth/2) - Math.round(pre_loader.width/2);
    pre_loader.y = Math.round(stage.stageHeight/2) - Math.round(pre_loader.height/2);
    pre_loader.load_bar.width = 1;
    // load page
    loadThisPage(this_page);
    //======================================================================================== =================================================
    //    load called page
    //======================================================================================== =================================================
    function loadThisPage(thisPage:String):void{
    // load new page
    background_ldr = new Loader();
    var pageRequest:URLRequest = new URLRequest(thisPage);
    background_ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, pageCompleteHandler);
    background_ldr.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, pageProgressHandler);
    background_ldr.load(pageRequest);
    function pageCompleteHandler(loadEvent:Event){
    background_mc = MovieClip(background_ldr.content);
    background_holder.addChild(background_mc);
    removeChild(pre_loader);
    function pageProgressHandler(e:ProgressEvent){
    var loaded:Number = e.target.bytesLoaded;
    var total:Number = e.target.bytesTotal;
    var pct:Number = loaded / total;
    trace(pct);
    pre_loader.pct_txt.text = String(Math.round(pct * 100)) + "%";
    pre_loader.load_bar.width = Math.round(pct * load_bar_width);
    THE LOADED SWF
    This file also used the default settings for Flash player 10. Therefore, I am not merging into the code my tlf library so no increase in file size.
    The doc class:
    package com {
    // core
    import flash.display.MovieClip;
    import flash.display.Stage;
    import fl.text.TLFTextField;
    import flash.events.Event;
    // import custom classes
    import com.main.BuildStageClass;
    // initialize class
    public class DocClass extends MovieClip {
      // custom classes
      // variables
      public static var build_stage_class:BuildStageClass;
      // stage containers
      public static var main_stage:MovieClip;
      // private toggle var
      private var init:Boolean = false;
      // main constructor
      public function DocClass() {
       addEventListener(Event.ADDED_TO_STAGE, stageAddedHandler);
      private function stageAddedHandler(e:Event){
               // trace("Document Class Stage: " + this.stage);
       // initialize classes
       build_stage_class = new BuildStageClass();
       // wait until second added to stage call to initialize application
       if(init == false){
        init = true;
       else{
        removeEventListener(Event.ADDED_TO_STAGE, stageAddedHandler);
        // add containers to stage
        main_stage = new MovieClip();
        addChild(main_stage);
        // start app
        startApplication();
      public function startApplication():void{
       //trace("here at start");
       // build stage
       build_stage_class.buildStage();
    This works 100% for me without using the safeloader in the preloader.swf. I've experienced some issues with the safeloader before so not using it is a blessing.
    I hope this helps someone! Enjoy.

  • Preloader ignores external swf's actionscript

    Hey guys
    I have an External.swf file that is a video. The swf is 1135 frames long and running just fine by itself, stopping as I want when the actionscript says stop(); on the first frame and looping the end of the clip with gotoAndPlay(837).
    The preloader SwfLoader.swf linked to the External.swf shows the percentage of bytes loaded as it should. However, it runs the video (sound playing in the background) while the preloader shows the loading progress I think it's because it doesn't load the first frame first.
    Once the external swf is loaded, it plays the video again, still ignoring the first actionscript frame that says stop(); and the last frame gotoAndPlay(837).
    Thank you.
    Here is the preloader's actionscript on the first and only frame:
    import flash.geom.*
    import flash.display.*
    var loadurl:String = "External.swf";
    var nDepth:Number = 0;
    var nWidth:Number = 200;
    var nHeight:Number = 20;
    var nPadding:Number = 3;
    var cLoader:MovieClipLoader = new MovieClipLoader();
    var oListener:Object = {onLoadInit:onContentLoaded};
    var mcLoader:MovieClip = this.createEmptyMovieClip("Loader_MC", 0);
    var mcContent:MovieClip = this.createEmptyMovieClip("Content_MC", 1);
    var mcLoadBarBg:MovieClip = mcLoader.createEmptyMovieClip("LoadBarBg_MC", nDepth++);
    var mcLoadBar:MovieClip = null; //Duplicated later with mcLoadBarBg
    var txtPercLoad:TextField = null; //Create after duplication
    var cMatrix:Matrix = new Matrix();
    mcLoader._alpha = 0;
    cMatrix.createGradientBox(nWidth, nHeight, 0, nPadding, nPadding);
    cLoader.addListener(oListener);
    mcLoader.lineStyle(1, 0x000066, 100);
    DrawRect(mcLoader, 0, 0, nWidth, nHeight);
    mcLoadBarBg.lineStyle(1, 0x0000FF, 0);
    mcLoadBarBg.beginGradientFill("linear", [0x006699, 0x0066FF], [100,100], [0, 255], cMatrix, SpreadMethod.PAD);
    DrawRect(mcLoadBarBg, 0, 0, nWidth - nPadding*2, nHeight - nPadding*2);
    mcLoadBarBg.endFill();
    mcLoadBar = mcLoadBarBg.duplicateMovieClip("LoadBar_MC", nDepth++);
    txtPercLoad = mcLoader.createTextField("PercLoad_TXT", nDepth++, 0, 0, nWidth, nHeight);
    mcLoadBar._alpha = 80;
    mcLoadBarBg._alpha = 30;
    Translate(mcTextMask, nPadding, nPadding);
    Translate(mcLoadBarBg, nPadding, nPadding);
    Translate(mcLoadBar, nPadding, nPadding);
    mcLoadBar._xscale = 0;
    mcContent._alpha = 0;
    mcContent._lockroot = true;
    mcLoader._x = Stage.width/2 - mcLoader._width/2;
    mcLoader._y = Stage.height/2 - mcLoader._height/2;
    txtPercLoad._x = mcLoader._width/2 - txtPercLoad._width/2;
    txtPercLoad._y = mcLoader._height/2 - txtPercLoad._height/2;
    SetTextFormat(txtPercLoad, "0%");
    mcLoader._alpha = 100;
    cLoader.loadClip(loadurl, mcContent);
    _root.onEnterFrame = function()
       var nBytesLoaded:Number = mcContent.getBytesLoaded();
       var nBytesTotal:Number = mcContent.getBytesTotal();
       var nPercLoaded:Number = Math.round(nBytesLoaded / nBytesTotal * 100);
       if(nPercLoaded > 0)
          SetTextFormat(txtPercLoad, nPercLoaded.toString() + "%");
                mcLoadBar._xscale = nPercLoaded;
    function onContentLoaded(Void):Void
       //trace(_root + "::onContentLoaded");
       SetTextFormat(txtPercLoad, "100%");
       cLoader.removeListener(oListener);
       delete _root.onEnterFrame;
       delete oListener;
       delete cLoader;
       _root.onEnterFrame = function()
          //trace(_root + "::onContentLoaded::_root.onEnterFrame");
                var nInc:Number = 5;
                mcLoader._alpha -= nInc;
                mcContent._alpha += nInc;
                if(mcLoader._alpha <= 0) startLoadedContent();
    function startLoadedContent(Void):Void
       delete _root.onEnterFrame;
       mcLoader.removeMovieClip();
       mcContent._alpha = 100;
       mcContent.play();
    function DrawRect(mc:MovieClip, nX:Number, nY:Number, nW:Number, nH:Number, nR:Number)
       trace("DrawRect in: " + mc);
       if(nR == undefined) nR = 6;
       mc.moveTo(nX+nR,nY);
       mc.lineTo(nX+nW-nR,nY);
       mc.curveTo(nX+nW,nY,nX+nW,nY+nR);
       mc.lineTo(nX+nW,nY+nH-nR);
       mc.curveTo(nX+nW,nY+nH,nX+nW-nR,nY+nH);
       mc.lineTo(nX+nR,nY+nH);
       mc.curveTo(nX,nY+nH,nX,nY+nH-nR);
       mc.lineTo(nX,nY+nR);
       mc.curveTo(nX,nY,nX+nR,nY);
    function SetTextFormat(txtField:TextField, sText:String)
       var txtFmt:TextFormat = new TextFormat();
       sText = "Loading... " + sText;
       txtFmt.font = "Verdana";
       txtFmt.align = "center";
       txtFmt.size = 11;
       txtFmt.color = 0x000066;
       txtFmt.bold = true;
       txtField.selectable = false;
       txtField.text = sText;
       txtField.setTextFormat(txtFmt);
       txtFmt = null;
    function Translate(mc:MovieClip, nX:Number, nY:Number):Void
       mc._x = nX;
       mc._y = nY;

    Hi kglad,
    The external swf is a movieclip (flv embedded with an AS3 layer to control the timeline) exported as an swf file .
    The first frame of the external swf is just stop();
    I didn't know the proloader code was AS2 though
    The preloader works fine with the external swf locally, but the problem happens when I run them from my server.
    The external swf itself and its code works fine from the server, both combined don't, so I guess the problem comes from the preloader. Probably because of the AS being 2 insted of 3.

  • MCL and PreLoader Debacle

    Hello...thanks in advance, especially those (kglad) who have
    been responding to previous posts of mine regarding this same
    problem. I'm going out of my mind though with this...basically I
    have an extremeley tempermental flash movie which plays differently
    in almost every browser (I'm on a mac, using safari and ff, but I
    just tested on a pc, and it was the same).
    I can not for the life of me figure this out. I practically
    copied the code right out of a book I read, and it made sense in
    there, but it's escaping me out here in the real world. Am I insane
    for doing it like this? It seems rather easy and simple, and just
    what I'm looking for. Here's what I want:
    1) create an instance of a movieClipLoader
    2) give that movieClipLoader a listener, launching a
    preLoader every time that mcl loads
    3) load in external .swf's using that mcl by clicking on
    buttons...every movie has a stop action on its first frame, but the
    onLoadComplete of the preLoader instructs it to play again.
    That's about it. Simple eh? Not for me? Could you please take
    a look at my code and tell me what I'm doing wrong?
    Here are some issues I'm having in the browser:
    1) First time loading with cleared cache it's loading well!
    2) If I reload the page, none of my dynamic text loads in the
    preLoader work...also, the preLoader code that changes the size of
    a progress bar doesn't run, so the preLoader .swf is stuck on frame
    1
    3) All three buttons work great the first time, but if I
    click each of them again, the .swf parks on frame 1 (click the
    music button to see an example of this.
    4) If I reload the page, sometimes the buttons don't work
    (most of the time actually), although sometimes they do.
    I've spent a little over a week trying to figure this
    out...here's a link to my main files...I hope we can get to the
    bottom of this.
    http://www.servinitup.net/bull/files/
    Thanks!
    Kevin

    So I guess I am insane?
    Anyone have any ideas? I know it's a pain to have to look
    through my .fla...I'd be much obliged though. It's the only way I
    know how to thoroughly explain my problem...
    Kevin

  • XML Preloader

    Hi all
    I'm going to be faced with trying to load a 3000+ node XML
    file into Flash.
    With something that big, ideally, I would like to incorporate
    some sort of preloader in Flash, so as the XML loads, you can see
    its progress.
    But I'm wondering if showing load progress for an XML file
    will actually work. Its always been my experience that Flash can
    only load XML as fast as the XML will load in a browser, but Flash
    doesn't show anything loaded until the whole XML is loaded.
    There is, in the Flash Help Files, an example of
    getBytesLoaded() and getBytesTotal() for XML files, but those don't
    seem to work at all.
    Searches on Google only come across other people asking the
    same questions with little or no answers.
    So I'm wondering if this is even possible. Can Flash show the
    progress of a loading XML file, before the XML file has finished
    loading? If so, where can I find how to do this?
    Thanks again for the help
    Chris

    Like I said, I've started with the method in the Flash 8 help
    files:
    // create a new XML document
    var doc:XML = new XML();
    var checkProgress = function(xmlObj:XML) {
    var bytesLoaded:Number = xmlObj.getBytesLoaded();
    var bytesTotal:Number = xmlObj.getBytesTotal();
    var percentLoaded:Number = Math.floor((bytesLoaded /
    bytesTotal )*100); //<--funny thing here, they left out the *
    before the 100 in the help file, throws up a syntax error
    trace ("milliseconds elapsed: " + getTimer());
    trace ("bytesLoaded: " + bytesLoaded);
    trace ("bytesTotal: " + bytesTotal);
    trace ("percent loaded: " + percentLoaded);
    trace ("---------------------------------");
    doc.onLoad = function(success:Boolean) {
    clearInterval(intervalID);
    trace("intervalID: " + intervalID);
    trace("doc: "+doc);
    doc.load("
    http://www.helpexamples.com/flash/xml/ds.xml");
    //<--Fairly long, publicly available, XML file
    var intervalID:Number = setInterval(checkProgress, 100, doc);
    The trace results I get when I run this are:
    milliseconds elapsed: 545
    bytesLoaded: 0
    bytesTotal: undefined
    percent loaded: NaN
    milliseconds elapsed: 711
    bytesLoaded: 0
    bytesTotal: undefined
    percent loaded: NaN
    milliseconds elapsed: 877
    bytesLoaded: 0
    bytesTotal: undefined
    percent loaded: NaN
    milliseconds elapsed: 1043
    bytesLoaded: 0
    bytesTotal: undefined
    percent loaded: NaN
    intervalID: 1
    doc = [giant XML file]
    So the bytesLoaded and bytesTotal are always 0 and undefined.
    kglad, how does your method work?
    Thanks again for the help.
    Chris

  • Preloading 2nd movie while 1st plays

    I have two movies,
    Animation01.swf (30K) and
    animation02.swf (2MB). Additionally, I have a preloader
    movie,
    preloader.swf.
    What I am trying to do is from the preloader.swf is to load
    the first move (Animation01) and as soon as it finishes loading, to
    play it. While Animation01 is playing, I'm trying to preload
    Animation02 in the background. Animation02 must only begin playing
    after the first one finishes.
    On the first frame of Animation01 and Animation02 I have a
    boolean variable
    donePlaying set to
    false. On the last frame of each animation I set the
    donePlaying variable to
    true so I can access it from the preloader. I am doing this
    (incorrectly?) to know if the current movie has finished playing so
    I can start playing the second one.
    I have searched high-and low and have seen discussions on
    what is almost the same problem/solution. From these discussions I
    have created the code below. What is happening right now is that I
    can't seem to call
    moviesLoaded[0].play()... Meaning that nothing plays. If I
    remove the
    targetMc.stop() from inside the
    onLoadComplete event handler, then both movies play right
    away atop each other :(

    Kglad, your suggestion did not work (or I still didn't
    understand you.)
    Ok, my deadline is tomorrow (it's 2am now)... ouch. One thing
    I realized is that the previous code I posted is needlessly
    complex, as it takes an arbitrary number of movies to preload. This
    is dumb because I only want to preload two movies. So, I tried
    simplifying it a bit. Following is the logical concept of the
    movies I have:
    preloader.swf
    |___FrontEnd-Ext-v16.swf (first movie to preload)
    |
    |___Mesozoic_Animation-v32.swf (second movie to preload)
    Now it seems I have two problems. My handlers are not getting
    called on the INIT event of the Loaders. Also I can't seem to
    access the Loader.content so I can do something like
    mcLoaderOne.content.stop(). Some one, kindly tell me where
    in my code I'm making the mistake(s).
    FYI - This is pertaining to ActionScript 3. My goal is to
    preload one move then play it automatically. While the first move
    plays, the second movie will be preloaded into cache. When the
    first movie finishes playing and the second movie is done loading,
    then play the second movie. Here's the new code I've written.

  • Preloader causes SWF to download twice

    Hi there,
    I'm wondering if anyone else has run in to this issue, where
    a movie with no 'export for runtime sharing' assets will be
    downloaded twice when accessed via a preloader script (see
    preloader code below). In this case, the SWF file 'main.swf' is
    downloaded twice - the second time straight after the preloader has
    finished with it. This is not usually detectable as most browsers
    cache the movie and it is instantly taken from cache, however on
    browsers that have the cache turned off this can be a very slow and
    frustrating experience.

    Hi kglad,
    At first that seemed like a silly comment, but it forced me
    to double-check everything. After the original block of code above,
    the movie continues to play an animation on the main timeline,
    always returning to the 2nd frame when done (the frame after the
    code above). In the full code for the onLoadInit event I had a
    _root.gotoAndStop(1); (see below) which called the movieclip
    main.swf to load again... I have changed this to
    _root.gotoAndStop(2); and it now works as intended.
    Thanks for the starter! :)
    -Shannon

  • Preloader Text (numbers) not showing

    Hi,
    I have a preloader and I've noticed that the percent_tf.text doesn't always show the percent loaded.  Any ideas?
    Thanks,
    Chris

    Hi kglad,
    Thanks for the response.
    I did embed the font . . . though I selected only numbers as only numbers should appear.  Is that reasonable?  The color isn't the issue and the problem is intermittent -- sometimes I see the numbers and other I don't.
    Any ideas?
    Thanks,
    Chris

  • Preloading multiple dynamic images

    I've searched this topic for hours with no luck. Basically I
    have an XML file with a description and the url of multiple images.
    When I play the flash movie the nodes of the XML are loaded into an
    array and then each jpg is then loaded and attached to a movie clip
    along with the description using a for loop. The problem I'm having
    is that when making a preloader it only preloads one of the images.
    OR if I use an external preloader, the swf file is preloaded but
    none of the images are. Is there a way that I can preload all of
    the images or preload each movie (with the image and description
    attached) in the for loop? Thanks!

    How odd is that. The createEmptyMovieClip() method of the
    MovieClip class was available in Flash 6 (Also known as Flash MX).
    It is true that the MovieClipLoader class was not available until
    MX04.
    And as Kglad said, there is no way to load things without
    loading them into some kind of target. So you can load into
    movieclips that are hidden or something, but cannot load into
    movieclips that don't yet exist.
    I tend to think of this classic problem in a slightly
    different way. To my mind the preloader isn't there to necessarily
    show how many bytes have been loaded and how many remain. I tend to
    think it is communicating that progress is being made –
    variable internet traffic, server load, etc. can mean that the
    datarate will fluctuate. So if you are loading several files that
    are roughly the same size (say within an order or magnitude) just
    advance the preloader for each file loaded.
    Say you were loading 9 files total, then each file loaded
    would be about 11 percent (file percent = 1 / total number of
    files).
    Just a different way of thinking about it. Maybe it will give
    you some ideas.

Maybe you are looking for

  • Dynamic insert for Special Characters

    Hello, I'm running into a problem inserting data with Special Characters. I have a report (designed oracle reports), that takes data and inserts the data into table. I use the SRW.do_sql built in package in a before report trigger to process the data

  • SOLVED What benifits are there to Blank Padding values in a DB?

    I was witting some SQL last week and got really frustrated when I couldn't figure out why my joins were not working from on DB to another. I eventually found that there where blanks tagged on to the end of all of the values of one of the columns I wa

  • Radiobuttons and the focus event

    This is in AS2. Is there a 'onFocus' event for individual radio buttons,  or is it limited to the radiobutton group ? If there is a focus event for the buttons,  how to I set it up ?  I've set up an event listener with an 'onFocus' event,  'gotFocus'

  • Core i7 HP Pavilion DV6 6011tx heats up-to 57C when idle and rises up-to 90C when on load!

    Hi... I have an HP Pavilion DV6 6011tx laptop.. (with a core i7 cpu and 6GB ram).. When im using the laptop for browing, the temperatures rise upto 55 to 60 C! (Even with a cooling pad)... Yesterday, i tried to render a video with adobe premier... T

  • HT1428 I want to change the name of my macbook Help ?

    I tried enabling the rooy account and then renaming the folder with the house on it which was my account but it does not allow my to change my acoount's name Help ? Thanks