8 Replies Latest reply on Aug 11, 2013 5:33 AM by 3x7x37

    Buttons in Flash CS6

    3x7x37 Level 1

      Hi There,


      I am new to flash and would like to know how to make a button go to a designated frame using ActionScript 3.0!


      I have several buttons in my interface (they all have different instance names) and would like them all to go to different frame markers within my application.


      Can someone help me out with this basic request. I did do some work in Flash many years ago but this new interface (CS6) looks very different to anything I have seen before.


      Thanks heaps and TLK soon.




        • 1. Re: Buttons in Flash CS6
          Ned Murphy Adobe Community Professional & MVP

          Here is one basic way, where each button has a function dedicated to clicking it...


          btnName.addEventListener(MouseEvent.CLICK, gotoFrame10);


          function gotoFrame10(evt:MouseEvent):void {





          Another way would be to have a single shared function that determines which frame is desired based on some information from the button... like using a number in its name, or a property that you assign (movieclips as buttons).

          1 person found this helpful
          • 2. Re: Buttons in Flash CS6
            3x7x37 Level 1

            Thanks Ned,


            What I would actually lke to do is ask the playhead to go to a frame with an instance name, like for example when I click one of the buttons I would want the playhead to go to a frame called "Typography" and obviously there are many different names in different places on the timeline.


            Can this be done?

            • 3. Re: Buttons in Flash CS6
              Ned Murphy Adobe Community Professional & MVP

              You could use the name of the button as the frame label and then just replace the frame number with the button's name.  You could do that generically using...


              typography.addEventListener(MouseEvent.CLICK, gotoFrame);

              videography.addEventListener(MouseEvent.CLICK, gotoFrame);


              function gotoFrame(evt:MouseEvent):void {




              It should be noted that the instance names can be acquired from the name property if the object was manually created/planted on the stage.  If the object was created dynamically, its name property is not the same animal.


              I used lower case names as a matter of coding convention.  Class names start with a capital letter by convention, so it is less confusing to not use them elsewhere for someone who plays by the conventions when they read your code.

              1 person found this helpful
              • 4. Re: Buttons in Flash CS6
                3x7x37 Level 1

                Sounds pretty good although I am still getting to know the terminology and have realised there is a lot to learn. The problem I am facing right at the minute is that I am not being allowed to copy and paste code into the ActionScript window for some reason (see attached pic). That unfortunately therefore renders the supplied code somewhat unuseful.


                Here is the process I am following:


                1. I click on the button on the stage

                2. I go to the ActionScript window

                3. There is a notification there disallowing me to paste code (as you will see in the picture). Instead I have to click the Code Snippets icon in the top right and input code that way. Which I have done successfully when it comes to for example: clicking my stage buttons and going to a frame number or stopping at a frame, and there are other very useful snippets which I can see myself using in the future. It turns out though that there is no snippet for going to frame labels which I have created. They are called but_1, but_2, but_3 etc etc...and you can see the last one "but_8" on the picture.


                If there was some way to use the ActionScript code generator (in the left part of the ActionScript window) to create the code I need, or if there is some way to use, modify or create a snippet then I would prefer to do this and familiarise myself with the process, thus encouraging myself to think about the code I am creating.


                I have a hunch that one can use the ActionScript to the left of the screen to generate code snippets. Is that correct?


                Here are some pics for you to look at.


                Your help with this would be so much appreciated you seem to know what you are doing. Thank you very much for helping me.







                • 5. Re: Buttons in Flash CS6
                  Ned Murphy Adobe Community Professional & MVP

                  AS3 files do not allow code to be attached to objects (a bad practice that should never have been).  All code goes in the timeline.  Select a frame where the objects are (a separate actions layer is best) and place it there.

                  1 person found this helpful
                  • 6. Re: Buttons in Flash CS6
                    3x7x37 Level 1

                    Very True Ned I have noticed this and the interesting thing is that flash CS6 automatically does this if you use the Code Snippets method for generating code. Here is how I know:


                    If I select my button on the stage, then use the code snippets method, flash automatically inputs the code in the location of my playhead, on the layer named actions.


                    If I then go back to the stage and select my button there will be no code there, instead, all the code I just made is contained on the timeline where the small "a" is.


                    It appears to me that this method has the added benefit of not having to type or re-type the name of objects in my movie but instead shoves their pre-nominated names straight into the right location. To my mind this minimises the risk of malfunction due to user error...and my typing skills are not exactly fantastic if you know what I mean.


                    This is what led me to believe I can use snippets effectively. Are you saying there is no way to use snippets for this? or to create a snippet which will do this?


                    I am one of those people who likes to click things inside the software, or in other words learn how to use the software to generate peices of code, and learn how the developers intended the software to be used as a tool for those of us less code savvy!


                    Any help with the code breakup you supplied, and where it comes from (inside the software) would be greatly appreciated.




                    • 7. Re: Buttons in Flash CS6
                      Ned Murphy Adobe Community Professional & MVP

                      I don't know what kind of help you are looking for with the code I supplied.  You name your buttons and create the code for them.


                      I do not use snippets. Some time around 10 years ago when I first started using Flash I tried it and dropped it almost immediately.  Coding by hand has no match and doing so keeps you on your toes and helps you learn.


                      They do not design software like this to make is so that anyone can use it to its fullest potential without having to learn anything... quite the contrary to that.  The days of the WYSIWYG are lost to the past.

                      1 person found this helpful
                      • 8. Re: Buttons in Flash CS6
                        3x7x37 Level 1

                        I know what you mean but I have always personally found the user interface method far more satisfying. It depends on ones priorities...and plus the developers are really smart and they make it vey user friendly.


                        This is the same for dreamweaver but obviously there are always some things (the so called tricks of the trade) for which there is no option but to code, or cut and paste.


                        I have also noticed that coders (and I have met a few) seem to have limited social lives, questionable interpersonal skills and generally think they are better than everyone else. I have therefore made a deliberate decision not to spend countless hours typing what is to most people...gobbledygook.


                        LOL :)