A Flash Developer Resource Site

Results 1 to 15 of 15

Thread: Preloader for external swf

  1. #1
    Member
    Join Date
    Oct 2005
    Posts
    66

    Preloader for external swf

    How do I go about having a preloader for an swf I am loading externally?

    So Basically I would like the preloader to load into my MC I have on the stage called "movieloader" and once it hits 100percent, load my external swf into "movieloader"

    Here is the preloader code i'm currently using for my gallery images which load into "movieloader". Can this be modified to do as described above?

    frame 1:
    total_bytes = _root.movieloader.getBytesTotal();
    loaded_bytes = _root.movieloader.getBytesLoaded();
    percent_done = int((loaded_bytes/total_bytes)*100);
    percentage = int((loaded_bytes/total_bytes)*100)+"%";
    bar.gotoAndStop(percent_done);
    ifFrameLoaded ("pictures", 3) {
    gotoAndPlay("pictures", 3);
    }

    frame 2:
    gotoAndPlay(1);

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    in my footer is a link called preloader help.. they are work for loading EXTERNAL content (like .swf's).. one is even a component I made for quick usage or noobies.

  3. #3
    Member
    Join Date
    Oct 2005
    Posts
    66
    so this requires the external swf to have a blank frame in the first frame of it?
    Unfortunately I can't modify the existing swf.
    I tried using the example fla, but the preloader didnt work, just displays with no progress, i'm assuming because the external swf doesnt have the first frame blank and stopped...
    anyways i tried it without a preloader and it seemed to work okay...which is a little strange since its 1.5 mb, i would have expected a big delay. But it pops up right away and starts playing...
    but i'll hang onto the preloader code for future reference.

  4. #4
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    they external.swf does NOT need a blank frame if you do NOT want it to..

    have you tried to use the component? it would be much easier for you Im sure..

    are you loading it locally? that may be why you saw no 'lag' in loading times.

  5. #5
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    this is tutorial which will get you on the way:

    External SWF Preloading at www.gotoandlearn.com
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  6. #6
    Member
    Join Date
    Oct 2005
    Posts
    66
    Quote Originally Posted by whispers
    they external.swf does NOT need a blank frame if you do NOT want it to..

    have you tried to use the component? it would be much easier for you Im sure..

    are you loading it locally? that may be why you saw no 'lag' in loading times.
    I'll have to play around with it a bit more.

    No its loading from a web server.

  7. #7
    Member
    Join Date
    Oct 2005
    Posts
    66
    alright, took another shot at it today...less tired . Got it working correctly, not sure what i did last time, but works now, substituted in differently graphics that match my existing preloader.

    So one question now...since the external swf i'm loading isnt stopped on the first frame(and i cant modify this swf as I dont have the fla), it starts playing as it loading.
    Can I target this swf on the button with code so it doesnt start playing?
    Here is whats on the button right now:
    on (release) {
    _root.transition._xscale = 79;
    _root.transition._yscale = 88;
    _root.transition._x = 515;
    _root.transition._y = 400;
    _root.transition.gotoAndPlay("in");
    _root.load = "tutorials_swf/PS_blending_options_tutorial.swf";
    _root.container._xscale = 100;
    _root.container._yscale = 100;
    _root.container._x = 112;
    _root.container._y = 64;
    }

  8. #8
    Member
    Join Date
    Oct 2005
    Posts
    66
    alright i spoke too soon. I modifed your example file to suit my site, published, tested and works.
    I create a new document select the frames on all layers, copy and paste into the new document, publish and it doens't work....I don't understand how, everything is exactly the same, just pasted into a new file...??? very frustrating, what gives?

  9. #9
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    no clue...copy/pasting always causes problems..

    as for 'what gives'? how could I tell? its like asking you wants wrong my car? (and I havent shown you anything about it)

    are you using a movieClipLoader() instance? you should be..

    either way you can try to use containerClip.stop(); to stop the external.swf from playing.. not sure it will work though..

  10. #10
    Member
    Join Date
    Oct 2005
    Posts
    66
    Quote Originally Posted by whispers
    no clue...copy/pasting always causes problems..
    Really? copy/pasting always causes problems!?....never heard that before..okay in that case i will try remaking it in my current fla and see if that fixes it.

    Quote Originally Posted by whispers
    as for 'what gives'? how could I tell? its like asking you wants wrong my car? (and I havent shown you anything about it)
    Yah i know...just whining and banging my head against the monitor

    Quote Originally Posted by whispers
    are you using a movieClipLoader() instance? you should be..
    Yup

    Quote Originally Posted by whispers
    either way you can try to use containerClip.stop(); to stop the external.swf from playing.. not sure it will work though..
    Okay, i'll give it a try
    thanks

  11. #11
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    hmmok.well it shoudlbe too hard to fix.. if you can post your .fla I'll take a look..or if you want I can whip up a small movieClipLoader demo ..


    have you checked to make sure all the objects have instance names?

    what happens when you try YOUR version?..any errors?

  12. #12
    Member
    Join Date
    Oct 2005
    Posts
    66
    yup, everything has instance names, all code is there etc. Now that I think about it again I do remember having trouble with copy/pasting some time ago when I doing my portfolio disc...
    I'm sure it will work when I redo it in my fla. Like I said the fla of yours that I modified works fine, I can grab those frames copy/paste into a new fla and it won't work, all instance names, code etc is still there as it was in the original file, but just doesnt work for some reason. Basically it loads the swf, the transitions comes up the preloader pops up and sits a 0%.

  13. #13
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Are you copy and pasting to a new .fla that is saved as an F8 file?

    Im not sure what code or .fla your using.. but maybe it was an older MX version? (case sensative?) see if the Math.round() is typed as math.round() needs to be caps..

    only thing I can think off my head.

  14. #14
    Member
    Join Date
    Oct 2005
    Posts
    66
    You are the man! That was it, I just finished zipping up my modified example and my page so you could compare, but no need for that now...woohoo.
    I was also going to ask you about flash version since I noticed when I was remaking everything in my file, the text boxes mentioned something about flash 5 in your example file.
    Thanks for your help..still need try out the containerClip.stop(); thing yet.
    Well one issue down, two more to go I also have a scroller issue posted maybe you can shed some light on that for me??
    I will strip down the fla and upload an example in a bit.

  15. #15
    Member
    Join Date
    Oct 2005
    Posts
    66
    test_file

    here is my scroll issue if you care to take a look.
    Basically my gallery has thumbnails with a scroll bar to scroll and this works fine.
    I have another external swf that loads into an MC that uses the same scrollbar.
    That one loads and works fine, when I click to close and unload it my main scrollbar in my gallery no longer works....

    again..much appreciated, oh and I tried the container.stop deal and it didnt work...but i can live with that, i'm just happy the preloader is working finally.

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