12 Replies Latest reply on Apr 30, 2008 10:35 AM by Design4Horses

    loadMovie question

    Design4Horses
      I am trying to load an external swf using loadMovie and can't seem to get it to work.I have created the external swf and have it in the same folder as the main movie. I have created an empty movie clip named "container" and placed it on the timeline. Here is the code:

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

      My movie is 900 x 550. Here's a big question: WHAT SHOULD THE SIZES BE FOR MY CONTAINER AND EXTERNAL SWF??

      The graphic in the external swf (people.swf) is 200 x 227, but does the movie dimensions need to match the size of my main movie?

      I've tried it both ways and can't seem to get it to work. Any help is greatly appreciated!

        • 1. loadMovie question
          clbeech Level 3
          you need to change the call to point at the container clip without the quotes, and add parent since this code is attached to the 'button'.

          loadMovie('people.swf', _parent.container);

          the size wont matter for the loaded clip, it will show up at the position of the container clip on the stage at 0,0 of that clip.
          • 2. Re: loadMovie question
            Design4Horses Level 1
            hmmm....I see why that should work. But for some reason, it doesn't. I know I've done these before, this is baffling me.

            Thanks, though.
            • 3. Re: loadMovie question
              clbeech Level 3
              do you have an 'instance name' on the container clip - in the properties panel - named container?
              • 4. Re: loadMovie question
                Design4Horses Level 1
                well duh...I think I've found the problem. I am trying this in the trial version of CS3. Doesn't that use ActionScript 3? I should probably go back to my old standby...

                I'll post in the AS3 forum. I've found where someone had a similar question that was answered, except they didn't refer to using a button.

                Thanks for your help!
                • 5. Re: loadMovie question
                  Level 7
                  Design4Horses,

                  > well duh...I think I've found the problem. I am trying this in
                  > the trial version of CS3. Doesn't that use ActionScript 3?

                  Only if you configure your FLA file for AS3. You can change the Publish
                  Settings for ActionScript 2.0 or 1.0 and take your pick. :)


                  David Stiller
                  Adobe Community Expert
                  Dev blog, http://www.quip.net/blog/
                  "Luck is the residue of good design."


                  • 6. Re: loadMovie question
                    Design4Horses Level 1
                    No...I'm in Actionscript 2.

                    I do have an instance name of container on the movie clip container.

                    Would it have to do with the button calling the loadMovie being within another movie clip?

                    Here's what I've done:
                    - I have my main movie. (MAIN)
                    - Within MAIN movie, I created a movie clip that slides sideways (upon loading) and contains a series of buttons. (CONTACTBOX)
                    - I am placing the loadMovie code on a button within the CONTACTBOX movie clip.
                    - The exernally loading swf is supposed to load in MAIN.

                    Would the "parent" still apply here? I think so...

                    If you want to take a look at the movie, you can find it at:

                    http://www.equinemarketinggroup.com/kcomdraft/index.html

                    Go to the menu and hit the "contact" button. (Still early in construction!)

                    Thanks so much for any help.
                    • 7. Re: loadMovie question
                      Level 7
                      Design4Horses,

                      Woops! I'm not sure now if you're replying to clbeech or me, so I hope
                      I didn't end up hijacking this thread. I just wanted to make sure you
                      understood you can use Flash CS3 to code in ActionScript 2.0.

                      > No...I'm in Actionscript 2.

                      Coding in AS2 is fine, but you also have to make sure that your FLA file
                      is configured for AS2. See File > Publish Settings > Flash > ActionScript
                      version.

                      > I do have an instance name of container on the movie clip
                      > container.
                      >
                      > Would it have to do with the button calling the loadMovie
                      > being within another movie clip?

                      The hierarchical arrangement of your movie clips makes all the
                      difference. clbeech's suggestion was this:

                      loadMovie('people.swf', _parent.container);

                      ... which makes sense if container exists in the timeline of the parent
                      movie clip. You can get a quick idea whether or not you're correctly
                      referencing that container by using a trace statement:

                      trace(_parent.container);
                      loadMovie('people.swf', _parent.container);

                      Try that and see what you get in the Output panel.

                      > Here's what I've done:
                      > - I have my main movie. (MAIN)
                      > - Within MAIN movie, I created a movie clip that slides sideways
                      > (upon loading) and contains a series of buttons. (CONTACTBOX)

                      With ya so far.

                      > - I am placing the loadMovie code on a button within the
                      > CONTACTBOX movie clip.
                      > - The exernally loading swf is supposed to load in MAIN.

                      So where's the movie clip with the instance name "container"?

                      > Would the "parent" still apply here? I think so...

                      In ActionScript 2.0, the concept of a movie clip's parent is controlled
                      by the MovieClip._parent property -- in other words, a _parent property
                      (with underscore) -- which is available to all movie clips, because all
                      movie clips are defined by the MovieClip class.

                      If you're using on() to attach code directly to your button, then the
                      button's "point of view" is that of the movie clip in which it resides. In
                      this case, it sounds like that would be your CONTACTBOX clip. So in a
                      sense, your on() code thinks it exists in the timeline of CONTACTBOX. The
                      parent of CONTACTBOX would be what you're calling MAIN -- that is, the main
                      timeline. So if your CONTACTBOX clip (actually, a button *in* that clip,
                      but using on()) is referencing _parent.container, then there's got to be a
                      movie clip with the instance name "container" in the main timeline.

                      It doesn't sound like there's such a clip in this case.


                      David Stiller
                      Adobe Community Expert
                      Dev blog, http://www.quip.net/blog/
                      "Luck is the residue of good design."


                      • 8. Re: loadMovie question
                        clbeech Level 3
                        sounds like you're two level deep then if container is at MAIN and the button (MC) is in CONTACTBOX - so you'll need two _parent(s) or call to _root, so:

                        loadMovie('people.swf', _root.container);
                        • 9. Re: loadMovie question
                          clbeech Level 3
                          lol - sorry David - dang newsgroup posts don't show up right away lol!! :)
                          • 10. Re: loadMovie question
                            Design4Horses Level 1
                            Thanks for the explanations, guys! I tried the code that clbeech suggested, didn't work. Then I tried the trace code from David, and this is what it gave me: _level0.container.

                            I'm stumped. Should I email the FLA file to see if you see something I don't? (Which wouldn't be saying alot! :)

                            Thanks for the input...
                            • 11. Re: loadMovie question
                              clbeech Level 3
                              lol - you're welcome - but it is odd that '_root' then did not work since the trace shows that the container clip is in fact residing at _level0 - which is the main timeline or the '_root'. You could use: _level0.container - as long as this swf is not loaded into another.

                              the only other thing I can think of is that either a) the swf file 'people.swf' does not have that exact name - including the same capitalization, or b) it does not reside in the same directory (which you've said that it does) I'd check these as well, just to make sure.
                              • 12. Re: loadMovie question
                                Design4Horses Level 1
                                Weird...I decided to scrap the original file and start all over. Kept everything the same, used your code and now it works! Must have been some kind of bug, kinda strange. Anyway, thanks for all the help. You guys rock!