13 Replies Latest reply on Feb 7, 2007 9:05 AM by eLoCas

    Controlling main timeline from loaded movie

    eLoCas
      I have loaded an external movie onto the main movie in a movie clip called "mainholder" - In the main timeline on the main movie there is a "stop" command on frame 1. From the loaded movie, I want to control the main timeline and tell it to go to frame 2. Can someone tell me the actionscripting to do this, I have tried several commands and getting frustrated. ;-)

      Thanks
        • 1. Re: Controlling main timeline from loaded movie
          SymTsb Level 2
          movies are loaded into levels. The main movie is always considered level0 a.k.a _root in the AS. When you load a movie into another, the main movie is also considered the parent of that loaded movie a.k.a. this._parent in AS where this refers to the loaded movie. If you want something in the loaded movie to control the main timeline you could call it like this...

          _root.gotoAndStop(2); or _root.gotoAndPlay(2); depending on what you want.

          but because of the parent/child relationship, it can also be done like this....

          this._parent.gotoAndStop(2); or this._parent.gotoAndPlay(2)

          Although the first method is less to remember, the second method proves the most friendly and re-usable. Let me explain...

          Say that you did something like this....
          [MAIN MOVIE]
          [LOADED MOVIE]
          {Loaded Movie with buttons to control LOADED MOVIE}

          Your main movie loads a movie and when this loaded movie reaches it's 10th frame, it loads another movie where the buttons reside for controlling that clip. If you used _root in the button movie, it would cause the main movie (_root) to be called and not the LOADED MOVIE as you had intended during its design prior to trying to make this new main movie (and it would work as intended if you opened the LOADED MOVIE's fla file and exported). If you use this._parent in the button movie, it will always make it's calls to the LOADED MOVIE's timeline and not the main clips timeline.

          Sorry if this confuses you but it's important to understand.
          • 2. Re: Controlling main timeline from loaded movie
            eLoCas Level 1
            SymTsb - Thank you for your time - I understand what you are saying above Here is what I am trying to do, and just trying to think of different ways to accomplish it - and can't seem to figure out how.

            I have a main movie - I have a row of pictures that when one is clicked on it loads a movie clip showing a larger version of the pic. I simply want to have a button that says "close" or "x" similar to the way windows works - when you open up something you click on the upper right corner to close it. when clicked on closes down the window.

            I tried to have the button "unload" the movie, but I guess you cannot have a movie unload itself. Then I was thinking on the main movie I could have frame 2 have a command to unload the movie, so that is what I was talking about above.

            My other thought was to have an small transparent "command" movie at the upper left corner of the main movie - when clicking on the image "close" button have it load a movie into the "command" movie to tell it to close down.

            As you can see these are either creative or probably better described ridiculous ideas to try to simply unload the movie that don't seem to be working.

            If you can explain the easiest way to unload the image after it pops up, I would greatly appreciate your help.

            Again, thank you for your time.

            • 3. Re: Controlling main timeline from loaded movie
              sergiourra
              use a function...
              • 4. Re: Controlling main timeline from loaded movie
                eLoCas Level 1
                SymTsb - I just figured it out - It clicked when I read what you wrote

                "Your main movie loads a movie and when this loaded movie reaches it's 10th frame, it loads another movie where the buttons reside for controlling that clip. "

                I just loaded a "close" button movie into the larger image movie, so a movie in a movie on top of the main movie, and added the unload movie command to the button and it worked great.

                Again, thank you very much I have been trying to figure this out for hours. ;-)

                • 5. Re: Controlling main timeline from loaded movie
                  eLoCas Level 1
                  Sergioch - can you give me an example of a function you mentioned? Would that be a better way?
                  • 8. Re: Controlling main timeline from loaded movie
                    sergiourra Level 1
                    Forget the last two posts...

                    I've tested the next:

                    on(release){
                    unloadMovie(this._parent);
                    }

                    It removes the loaded movie where the button resides...

                    • 9. Re: Controlling main timeline from loaded movie
                      eLoCas Level 1
                      I tried it and it did unload it, but the only problem is, it unloaded the movie it resided in and also the main flash file, so the screen went white. If you could modify it to just unload the one movie that would awesome. Unless I am doing something wrong, but I put the button directly on the flash file, so it resided on it and added the script. - Thanks
                      • 10. Re: Controlling main timeline from loaded movie
                        SymTsb Level 2
                        if the button is in the main movie, using this._parent would be wrong. The instance name of the movie clip containing your loaded file should be there instead....

                        Remember, this._parent when used on any object stored in the main timeline refers directly to _root.
                        • 11. Re: Controlling main timeline from loaded movie
                          eLoCas Level 1
                          I have the main movie with a movie clip holder called- loadsgPhotosMain

                          When you press on the little image button is loads a movie called-
                          loadImageLarge0001.swf into the above holder

                          loadImageLarege0001.swf has the button on it that is part of that movie that says "close"

                          That is where I put the script-
                          on(release){
                          unloadMovie(this._parent);
                          }

                          That is what unloaded the loadImageLarge0001.swf movie, but also the main movie.

                          Then I tried applying the following to the button
                          on(release){
                          unloadMovie(this._loadsgPhotosMain);
                          }

                          And that doesn't unload it either- I really appreciate your patience - I am a novice when it comes to actionscripting.
                          • 12. Re: Controlling main timeline from loaded movie
                            SymTsb Level 2
                            ok... _ is only necessary for _parent and _root.... all other instance names are called by their name on the timeline soooooo.... in the case of this file try this

                            on(release){
                            unloadMovie(this._parent.loadsgPhotosMain);
                            }
                            • 13. Re: Controlling main timeline from loaded movie
                              eLoCas Level 1
                              Ah - perfect, thank you very much for your time, it is much appreciate. ;-)