A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Preloader not working in embedded flash

  1. #1
    Senior Member
    Join Date
    Apr 2001
    Posts
    222

    Preloader not working in embedded flash

    Hi guys,

    For some reason my preloader doesn't work once I embed the flash in HTML but if I link directly to the flash file it works. I am using swfobject.js to embed. Here's the preloader code:

    var total:Number;
    var loaded:Number;

    this.onEnterFrame = function()
    {
    total = _root.getBytesTotal();
    loaded = _root.getBytesLoaded();
    if (loaded >= total)
    {
    delete (onEnterFrame);
    gotoAndPlay("begin");
    }
    };
    stop();

    Any help would be greatly appreciated!

    Thank you!
    You have to think in Flash

  2. #2
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    What compiler are you using to create the swfobject.js?

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Here is a great tutorial that explains how to create the swfobject perfectly. The preloader should work in both methods, embed and swfobject.
    Actionscript Code:
    http://www.slideshare.net/macloo/how-to-use-swfobject

  4. #4
    Senior Member
    Join Date
    Apr 2001
    Posts
    222
    Thank you for your help! After some research and additional testing I realized that the preloader isn't working when the movie is being loaded into a parent swf. I have a parent swf that loads the child swf (with the preloader). When I view the child swf independently it works perfectly however when I view it within the parent swf, the preloader doesn't work. I am not sure how to solve :-( Any help would be greatly appreciated. Thanks again!
    You have to think in Flash

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    Look into MovieClipLoader();

    Thers plenty of topics in here.

  6. #6
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    That's even more weird, because, I have called child movieclips into a parent movieclip, and the Prealoder of these child MC's works prefectly. I have this flash site i'm making, and the main flash file is the container, when you click the sections, it loads external swf's into an empty movieclip. And when it does, I can see the percentage of the preloader running locally and on the html page. The parent MC has its preloader also, and it works.

    Are you using
    Actionscript Code:
    ParentMovieClip.loadMovie("ThisChildSwf.swf");
    to load the childs ?

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi,

    I use a re-useable movieClipLoader for such things

    it needs to be coded inside your main movie (not your child clips, you can remove all preloaders from your child clips)


    Actionscript Code:
    // re-useable movieClipLoader

    myLoader = new MovieClipLoader();
    myPreload = new Object();
    myLoader.addListener(myPreload);

    myPreload.onLoadStart = function(Target) {
    // Do what ever you like;
    }

    myPreload.onLoadProgress = function(Target, lBytes, tBytes) {
    soFar = Math.round((lBytes/tBytes)*100);
    loading.text = soFar+"% Loaded";
    }

    myPreload.onLoadComplete = function(Target) {
    loading.text = "Complete";
    }
    myPreload.onLoadInit = function(Target) {
    // Do what ever you like;
    }

    // End

    then on your buttons or button, it is re-useable

    try this

    button 1

    Actionscript Code:
    on (release) {
        myLoader.loadClip("file1.swf", emptyMovie1);
    }

    button 2

    Actionscript Code:
    on (release) {
        myLoader.loadClip("file2.swf", emptyMovie2);
    }

  8. #8
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    Yes fruitbeard, that's even better. That will surely help our friend with his preloading issue, because he will have more control over the childs, with the parent

  9. #9
    Senior Member
    Join Date
    Apr 2001
    Posts
    222
    Thank you everybody for this. Worked like a charm. Will be using this in the future. Appreciate the help and guidance!
    You have to think in Flash

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center