A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Loading External Movies?

  1. #1
    Member
    Join Date
    Dec 2004
    Posts
    49

    Loading External Movies?



    I'm trying to load different external swf files into a container aka "movie clip"... with the click of a button(s).

    This is what I want to leant to do:

    1. Load a swf movie PRIOR to any clicking of any buttons.

    2. Load a movie on release

    3. Be able to do this for multiple bbuttons.

    4. Unload a movie with another click of a different button.

    5. Unload ALL movies with a the click of another button.


    I'm guessing each of the movies will have their own preloaders.. and thus this will be an advantage...

    I have no idea how to do what I have described but I have seen it done.. if someone could please help me out that would be great...



    ---------------------------------------
    I'm also not sure how I would implement a scroll bar into any movie.. I've never used scrollbars within flash...

    ---------------------------------
    If you could show me how to do this.. and you dont mind telling me the pros and cons that would be great.. thanks.

  2. #2
    How should I know!? Biff Tanon's Avatar
    Join Date
    Jun 2001
    Posts
    748
    Hi!
    To load a movie without pushing a button, just put this action in a frame:
    code:

    loadMovie("yourMovie.swf", "_root.contianer");



    To load a movie on a button use:
    code:

    on(release) {
    loadMovie("yourMovie.swf", "_root.container");
    }



    One thing to note. The path to your container clip is probably going to be different than what I have. (_root.container). Just make sure you include the entire path to the container clip and you should be gold!

    To unload the movies, just use removeMovieClip(); in the same way.

    Hope this helps!
    [something cool goes here]

  3. #3
    Member
    Join Date
    Dec 2004
    Posts
    49
    I'm not sure how I would find out the path to my containers..

    I'm assuming.. the path now is root..

    if I need to load movies in diff. folders.. does the calliing work like html?

    Thanks

  4. #4
    Member
    Join Date
    Dec 2004
    Posts
    49
    ok.. I'm still somewhat confused on how to work with the removeMovieClip command...

    should it look like this:



    Code:
    on(release) {
    removeMovieClip("movie 1.swf", "_root.container");
    
    }
    or like this:


    Code:
    on(release) {
    removeMovieClip();
    }
    Anyways.. neither worked for me...

    and BTW.. the other code worked so well.. I'm so confused.. I remember doing this before.. and it looked likea totally complicated task.. what's wrong here?
    Last edited by oligocene; 03-24-2005 at 04:23 AM.

  5. #5
    Beyond the Sea
    Join Date
    Mar 2000
    Posts
    997
    note that removeMovieClip only works on movieclips that have been placed on the stage by either duplicateMovieClip, attachMovie, or createEmptyMovieClip. If you created an MC by hand into which you will be loading the external files, you should use unloadMovie() to get rid of it.

    also, using dot notation is a lot easier to understand:

    ball.duplicateMovieClip("ball1",10);

    ball1.removeMovieClip();

    -------------------------

    _root.createEmptyMovieClip("ack",20);
    trace("ack!" + ack);
    ack.removeMovieClip();
    trace("ack gone!" + ack);

    --------------------------

    holder_mc.loadMovie("myPic.jpg");

    myButton_mc.onRelease = function() {
    holder_mc.unloadMovie();
    }
    The Coolest Website EVER!
    Do you live in Kansas City? Come join us at KCWebCore

  6. #6
    How should I know!? Biff Tanon's Avatar
    Join Date
    Jun 2001
    Posts
    748
    You could also use unloadMovie() to remove your clips...

    code:

    on (release) {
    unloadMovie ("_root.container");
    }



    To find the path to your clip, start at the root timeline. If your container clip sits right on the timeline, and your container MC has an instance name of "container" it would be:
    _root.container

    If it is inside of another MC with an instance name of "blue" -for lack of better words it would be:
    _root.blue.container

    Does that help?
    [something cool goes here]

  7. #7
    Member
    Join Date
    Dec 2004
    Posts
    49
    thanks.. that works .. but now lets say I want to load a different movie within the movie already loaded.. how would i do this...

    For example:


    I click a button , it loads movie x... now movie x is in a container.. and it also has some buttons.

    Now how do I make it so that movie x (in the container)... with buttons.. can load a new movie into the same container.. meaning it will unload itself first and then load the new movie into the container...so after I click the button on movie x, it would unload movie x and load movie y?


    What if I want to make a pop up container.. as for an image gallery.. that has a close option and can be dragged around.. is that more complicated?


    Another Question,

    How do I load multiple movies into container x and container y with the click of ONE button.

  8. #8
    Beyond the Sea
    Join Date
    Mar 2000
    Posts
    997
    you can use _parent to target the timeline above the one on which your button sits. So, if I loaded a SWF into a container called "mc2" that's on the main timeline and I had a button in there that I wanted to unload itself and load something different, I would use something like this:
    myButton.onRelease = function() {
    this._parent.mc2.loadMovie("mc3.swf");
    }
    The Coolest Website EVER!
    Do you live in Kansas City? Come join us at KCWebCore

  9. #9
    Member
    Join Date
    Dec 2004
    Posts
    49
    hmm

    Thanks...

    Question 1:
    "this.".. where do I find this info about my individual movies.. as in.. how do I find info about root, container paths in my movies.. thanks.

    Question 2:

    Creating an image gallery with a "pop-up" container that has an option to be closed, is that hard?


    THEORY:

    I was thinking about this code and the entire loading concept.. and I'm wondering if you could create a system where it's like a loop using else and if commands (or maybe some other code). You would have two or three movies that keep loading one another inside of each other =-/..

    Not something I want to do.. just a moment of theoretical thinking.
    Last edited by oligocene; 03-26-2005 at 09:29 PM.

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