11 Replies Latest reply on Feb 4, 2008 4:27 AM by MoCleveland

    Button referencing

      Ok, this is definitely a newbie question. For some reason I always get mixed up on "this" or "_root".

      I have a movie that loads a smaller movie using the loadMovieNum method. The loaded movie is called cwpTile.swf. I would like to add the onRelease function to a button in the cwpTile.swf file but I can't figure out how to reference it.
      The button in question is in a movie clip on the stage in cwpTile.swf and the movie clip is called "symbol 1" and the instance name is "mySymbol" .

      Now the "mySymbol" movie clip has a button in it called "myBtn".

      In the main movie I wanted reference that button but I cant figure out the proper syntax.

      I tried _root.mySymbol.myBtn but that didn't work.

      Any suggestions?


        • 1. Re: Button referencing
          WebXperience Level 1
          Try using _level0.mySymbol.myBtn. Also using the trace(); method to display the actual actionscript references, names, contents, etc of your defined MovieClips and variables has helped me in the past.
          • 2. Re: Button referencing
            MoCleveland Level 1
            Thanks for the reply.

            I forgot to mention that the movie is loaded into level 10. So I tried
            _level10.mySymbol.myBtn and that didn't work either.

            • 3. Re: Button referencing
              WebXperience Level 1
              _level0 is the reference used in place of the _root reference.
              Try using trace(this.mySymbol.myBtn); to findout what reference actionscript is looking for.
              • 4. Re: Button referencing
                MoCleveland Level 1
                thanks for the help

                oops not level0 but level10 as in level ten. That's the level the movie is loaded into.

                Ok the trace (this.mySymbol.myBtn) says undefined.
                • 5. Re: Button referencing
                  MoCleveland Level 1
                  Ok I traced it in the wrong place. Now it reads _level10.mySymbol.myBtn

                  Thanks again for the help
                  • 6. Re: Button referencing
                    WebXperience Level 1
                    Show me the code and maybe I can find the problem.
                    • 7. Re: Button referencing
                      MoCleveland Level 1
                      Ok, I took the button out of the mySymbol movie clip (for simplicity) and just left it on stage by itself in the cwpTile.swf movie. Now I am able to reference the button as _level10.myBtn (your trace method helped me with that).

                      But the "go to and play" function is not working.(see below) The button is loaded on level 10, Scene 2 and is meant to be a nav type button, so when clicked it unloads itself and sends the play head back to scene 1 frame 23 (of the main timeline). I tried using:

                      _level0.gotoAndPlay("Scene 1", 23); (Level zero not ten) but that didn't work.

                      So this is what I'm left with thats not working:
                      _level10.myBtn.onRelease = function() {
                      gotoAndPlay("Scene 1", 23);

                      Any ideas?

                      Thanks again.
                      • 8. Re: Button referencing
                        I got the same problem with my file. I have been trying to find out the reason of the problem for 3 days.

                        Today in another flash forum somebody wanted to see the problem with his own eyes, so i sent him my fla file. Then we realized that nobody except me could open my fla files. They see "unexpected file format" error.

                        Eventually here i am and the first topic i saw was this-one.

                        Is this a coincidence?.. Or there might be an update causing this error?..

                        • 9. Button referencing
                          muarra Level 1
                          Everybody absolutely must read this. Cos' I have exerted huge efforts to find out how a button works in a movieclip. And I have seen many forums that knows nothing about it. It's very simple but once you ask for it, nobody gives an answer.

                          quoted from another forum
                          This seems to be one of the most frequent questions for beginners and many others. Hopefully, this will explain the mysterious non working buttons inside movie clips.

                          Once you put a button in a movieClip the typical gotoAndPlay("Scene2",1) will not work...

                          That is a global function that works on the main timeline only...

                          So what you need to do is use the MovieClip Method by the same name... it differs in the fact that it only takes only one argument....and that is frameNumber or a frameLabel. FrameLabels when you're dealing with scenes make life a lot easier...so,here's how you do it...

                          Go to the first frame of the scene and put a "label". To assign a "label" to a frame... Select your frame.
                          *Then just go to Window>;Panels>;Frame and type your label in the Label box.
                          (* In Flash 8 or upper, select the scene and frame where you want to go to and enter a "label name" in the label box located in properties tab.)

                          Then on your button in your movieClip, put this:

                          on (release) {

                          Of course, replace "yourLabel" with the actual label you put on your frame...


                          What's wrong with this bracket character? & quot; means ''
                          • 10. Button referencing
                            WebXperience Level 1
                            use yourMovieClip.gotoAndPlay("yourLabel");
                            • 11. Re: Button referencing
                              MoCleveland Level 1
                              I found one of the problems with my file. I was using scene names and frame numbers, when I switched to just frame numbers it worked fine.

                              for example:

                              gotoandplay("scene 1", 23)

                              Changed to


                              and it worked.

                              Of course I also had to add the _level10 (thats ten not zero) reference.

                              thanks for you help.