14 Replies Latest reply on Nov 30, 2006 9:33 AM by kglad

    attachMovie and Variable hel!!!

    Beedy
      Ok I basically have a navigation which has 5 buttons. What I want to achieve is when one of the buttons is pushed the sub navigation slides out on the right of it. I had planned on creating an mc on the stage that only had a mc inside which has an alpha of 0. This mc is motion tweened over frames for the slide out and slide in effect. Ok now the confusing part, basically I have created an array -

      var select = new Array ("one", "two", "three");

      then declared
      two = "sub2"; (which is the name of an mc in the library I would like to load).

      So when one of the 5 buttons on the main menu is clicked, it declares

      this.onRelease = function() {
      select = "two";
      _root.sub.gotoAndPlay("close");
      };

      As the mc plays, say about in the middle it has an -

      attachMovie (select, "select", _root.getNextHighestDepth());

      This I hope would attach a submenu from the library into this mc which is then tweened. I'm trying to have just one motion tween set, that basically when an menu item is selected will load the desired sub menu into the motion tweened mc on stage. However I would like these sub menus to come from the library rather than load external swfs on. I hope this isn't too confusing, please help! Here is an example of a site which I am trying to accomplish this effect.
      rga
      It is the navigation on the left hand side. The navigation is probably structured a whole lot more complicated than what I could understand, but I hope the method I would like to try could get me similar results.
        • 1. Re: attachMovie and Variable hel!!!
          kglad Adobe Community Professional & MVP
          you probably have more than one issue. but to start, select is either an array or its a string variable. it cannot be both.
          • 2. Re: attachMovie and Variable hel!!!
            Beedy Level 1
            hey thanks for replying kglad. Ok so if 'select' can not be both, would I necessarily need an array? All I would like to do is be able to attach or load different menu's, which are MC's in the library into an MC on the stage. I figure if there is a generic variable which would equal to something depending on which button on the main menu a user pushes. This value would then equate to what needs to be attached on stage. I thought an array would be needed which would state the different selections ther are.
            • 3. Re: attachMovie and Variable hel!!!
              kglad Adobe Community Professional & MVP
              among other things, an array might be helpful if you need to relate, for example, two things that are not otherwise easy to relate. for example, button1,button2,button3 etc might need to reference "one","two" etc.

              you can use an array to help by making sure each button knows which number it is (button1.ivar=1,button2.ivar=2 etc) and populating your array "one","two" etc.

              you can then use selectA[this.ivar-] from within your button handlers to reference the correct string.

              however, that's not what you're doing.
              • 4. Re: attachMovie and Variable hel!!!
                Beedy Level 1
                Thanks again for your reply. Ok this seems to be getting a little difficult or hard for me to follow and I might have to use a loadmovie and just load each as a seperate swf. The reason I want to pass a variable is because when the button on the main stage is pressed it basically tells the generic animation to play, in the middle of that animation I had the attachMovie declaration, which I had hoped would accept the 'variable' from the button the user had pushed and then would load into the attachMovie. I'm fairly sure a direct variable could not be placed in the attachMovie, since it usually has to be placed in quotes, so I thought in some way either a list of variables (an array?) would be one method.
                • 5. Re: attachMovie and Variable hel!!!
                  kglad Adobe Community Professional & MVP
                  the button that has the following code attached should cause a movieclip with what linkage id to be attached to the stage (1/2 through sub's timeline)?

                  • 6. Re: attachMovie and Variable hel!!!
                    Beedy Level 1
                    This would declare that 'select' is now = "two" once pressed. What I had hoped is when it gets to the MC (1/2 through) to the attach call, that the generic linkID in the attach call 'select' would then now refer to what select is equal to, in this case "two". "Two" then I wanted to refer to the MC in the library named "sub2", which it would then load.

                    select = "two"; // Just declares globally that select is now equal to two

                    _root.sub.gotoAndPlay("close"); // is the mc that plays and half way through has the attach AS which would accept the global select value which corresponds to a movie in the library and load it.

                    I'm sure I am explaining it one way, however I'm sure the code doesn't operate that way.
                    • 7. Re: attachMovie and Variable hel!!!
                      kglad Adobe Community Professional & MVP
                      do you know if your movieclip has a linkage id? if yes, what is it/
                      • 8. Re: attachMovie and Variable hel!!!
                        Beedy Level 1
                        The linkage ID is the same as the name of the MC in the library, in this case "sub2", I also have Export for Actionscript checked.
                        • 9. Re: attachMovie and Variable hel!!!
                          kglad Adobe Community Professional & MVP
                          remove the code about an array and attached to your button use:

                          • 10. Re: attachMovie and Variable hel!!!
                            Beedy Level 1
                            ok I see where you are going with that. I did that, and it still doesn't work. Let me see if I have this correctly I got rid of
                            var select = new Array ("one", "two", "three");

                            I then have the declaration you have corrected on the button. Then I have the attach at the 1/2 point on the timeline on inside the mc which is animated. I made sure it is going to the exact location i.e. _root.blah blah attachMovie (select, "select", _root.getNextHighestDepth());

                            Still doesn't load anything
                            • 11. Re: attachMovie and Variable hel!!!
                              kglad Adobe Community Professional & MVP
                              then you have a path reference problem. you can simplify things if you use _root.select in your onRelease handler AND in your attachMovie's first parameter (the linkage id).
                              • 12. Re: attachMovie and Variable hel!!!
                                Beedy Level 1
                                Well I placed the _root.select on the onRelease of the button, so that it is now:

                                this.onRelease = function() {
                                _root.select = "sub2";
                                _root.sub.gotoAndPlay("close");
                                };

                                and I also changed it on the attach movie's first parameter which is:

                                _root.sub.tier2.holder.attachMovie (_root.select, "select", _root.getNextHighestDepth()); //holder is where I want the library clip to go (of course "sub2" is the name of the MC in the library as well as the linkageID name).

                                I believe I have all the bases covered, but it still doesn't load anything. The "sub" MC (look at the attach path) is masked, however I have tried with and without a mask and it still doesn't load, am I not seeing something?
                                • 13. Re: attachMovie and Variable hel!!!
                                  Beedy Level 1
                                  I GOT IT TO LOAD!!!! I decided to double check the properties of the MC in the library of "sub2". I had 'export for actionscript' checked in the linkage parameters, but I did not have 'export in first frame' checked. Once I checked that and published the movie again, it loaded. Thanks again for all your help!!
                                  • 14. Re: attachMovie and Variable hel!!!
                                    kglad Adobe Community Professional & MVP
                                    you're welcome.