A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 24

Thread: loading external SWFs ... then going to a specific frame?

  1. #1
    Member
    Join Date
    Jun 2004
    Posts
    79

    loading external SWFs ... then going to a specific frame?

    Hello!

    I want to load an external SWF file that has four parts (let's say: "about us", "contact", etc.) into my main movie.

    The file size of this external movie is big enough to require its' own loader.

    When the user clicks on a button on the main movie "about" (for instance) it will load the external SWF file ...fine. The loader will play then it will jump to the next frame ..."about" ...fine.

    BUT ...

    what if the user clicks on on a different button, say "contact" ???

    How do I get the the external SWF to load STARTING WITH THE LOADER and THEN know to jump ahead to frame 10, where "contact" begins?

  2. #2
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    try loading the movie say as MC

    then use
    on(press){
    _root.MC.gotoAndStop(10);
    }

    gotoAndStop/play commands can be used with movie clips to govern there indervidual timeline
    A spark of light in a dark wibbly wobbly world

  3. #3
    Member
    Join Date
    Jun 2004
    Posts
    79
    thanks!

    But won't it bypass the loader?

    So it will go to frame #10, but if the file's not loaded, there will just be blank space until it loads ...?

  4. #4
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    use an external loader as a holder so it is a movie that says loading... then is replaced when the new movie comes in at frame 10...

    or get mx2004 and use


    MovieClipLoader.onLoadStart handler is invoked when loading begins.
    MovieClipLoader.onLoadError handler is invoked if the clip cannot be loaded.
    MovieClipLoader.onLoadProgress handler is invoked as the loading process progresses.
    MovieClipLoader.onLoadInit handler is invoked after the actions in the first frame of the clip have executed, so you can begin manipulating the loaded clip.
    MovieClipLoader.onLoadComplete handler is invoked when a file has completed downloading.
    A spark of light in a dark wibbly wobbly world

  5. #5
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Not that easy my friend... Been at it for a couple of hours now and I know my way through preloaders... Have yet to get it working!

  6. #6
    Member
    Join Date
    Jun 2004
    Posts
    79
    OK ...I know nothing, but wouldn't it be something like:

    Each button on the main movie sends the message to load the external SWF with a different variable.

    The first frame of the incoming SWF has code that says something like:

    If variable "A" then play the loader and then jump to frame #15

    If variable "B", then play the loader and then jump to frame #20

    and so on...

    Eh?

  7. #7
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Was talking to tokyo_sky and not really to you my friend...

    Yes you're on the right track, and that's somewhat what I've been doing but the preloader bit is what's causing me problems... Because any button could be hit first...

    Waisted! Will look into it again tommorrow, if tokyo_sky doesn't come up with more than just suggestions!

  8. #8
    Member
    Join Date
    Jun 2004
    Posts
    79
    Thanks!

  9. #9
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    no oldnewbie i thought it was alot easyer so i hint good for learning and takes less time for me.... and you actually seem hostile??


    is this the sort of thing u want...

    main opens ext.swf
    ext has a loading scene only playes once... seems more sencible but can play it every time by moving the while statment
    Attached Files Attached Files
    Last edited by tokyo_sky; 10-21-2004 at 05:10 AM.
    A spark of light in a dark wibbly wobbly world

  10. #10
    Member
    Join Date
    Jun 2004
    Posts
    79
    Yeah ... he did seem a little hostile ...hmm.

    Thanks Tokyo sky!

    It will take me a little while to figure this out.

    I'm not totally sure where the loader should go. So if this works, no matter which button you press, it will load the external SWF, play the loader, and then jump to the frame you chose.

    The next time you click a button, it will go straight to that frame in the SWF because the SWF has already loaded. correct?

    Thanks again!

  11. #11
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    you got it!
    play around with it

    "I'm not totally sure where the loader should go"

    im not sure what loader you mean?? the loading scene? or the bit that loads the clip? ohwell if its a problem let me know...
    A spark of light in a dark wibbly wobbly world

  12. #12
    Member
    Join Date
    Jun 2004
    Posts
    79
    Thanks again!

    I'm using this as a loader:

    bytes_loaded = Math.round(this.getBytesLoaded());
    bytes_total = Math.round(this.getBytesTotal());
    getPercent = bytes_loaded/bytes_total;
    this.loadBar._width = getPercent*100;
    this.loadText = Math.round(getPercent*100)+"%";
    if (bytes_loaded == bytes_total) {
    this.gotoAndPlay(3);
    }

    I'll need to modify this slighty ... but does this go before your script:

    _root.loaddone = true;
    gotoAndStop(_root.frame);

    or after?

  13. #13
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    bytes_loaded = Math.round(this.getBytesLoaded());
    bytes_total = Math.round(this.getBytesTotal());
    getPercent = bytes_loaded/bytes_total;
    this.loadBar._width = getPercent*100;
    this.loadText = Math.round(getPercent*100)+"%";
    if (bytes_loaded == bytes_total) {
    this.gotoAndPlay(3);
    }

    percent = Math.round((this.getBytesLoaded()/this.getBytesTotal())*100)
    this.loadbar._width = percent;
    this.loadText = percent+"%";

    same code...

    put in ext.fla, frame 1, scene "loading"...
    if your wondering where the scene bit is press SHIFT+F2
    Last edited by tokyo_sky; 10-21-2004 at 06:21 AM.
    A spark of light in a dark wibbly wobbly world

  14. #14
    newayblue.com
    Join Date
    Jan 2002
    Location
    Leicester, UK
    Posts
    971
    External .swf preloader

    May be of some help

  15. #15
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Me, hostile? Sure, why not?

  16. #16
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397

  17. #17
    Member
    Join Date
    Jun 2004
    Posts
    79
    Wow! That's great ... exactly what we've been trying to do.

    can you share the secrets? (in plain english)

    Thanks!

  18. #18
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    No... Guess I'm much too hostile for that!

    But anyone that has a decompiler could easily find out!

  19. #19
    Senior Member tokyo_sky's Avatar
    Join Date
    Oct 2004
    Location
    Tokyo
    Posts
    201
    humm... you used _global instead of _root, what would the difference be? apart from that i like the naked ladies
    A spark of light in a dark wibbly wobbly world

  20. #20
    Banned
    Join Date
    Apr 2001
    Location
    Montréal, Québec.
    Posts
    25,397
    Well they aren't really naked! Was just to add some weight, 'cause the loaded movies weren't heavy at all, and I did somewhat want to see the preloader in action on a fast connection...

    As for _global, why not as in _global.hostile!

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