1 Reply Latest reply on May 21, 2016 11:31 AM by Colin Holgate

    How to make buttons work within all scenes?



      I have created four separate buttons (actionscript3) and I have coded each button so when one is clicked it jumps to a different scene. All four buttons are present on every scene (I copy & pasted all buttons from the original scene to every additional scene) so I was hoping that regardless of the scene the user can click on each button and have it work. Each button works on the first click (on the first scene) but the issue is once one is clicked and it jumps to a new scene the buttons no longer are clickable (the roll over state remains working but none of them work to being clickable to jump to another scene). I copy & pasted my code used below, hopefully this question makes sense, I just want my buttons to work regardless of the scene. Thank you!


      Here is the codes I have used, I placed it at the first frame of the first scene:


      tulip_btn.addEventListener(MouseEvent.CLICK, onClick);



      function onClick(e:MouseEvent) {

      gotoAndPlay(1, "Scene 2");






      rose_btn.addEventListener(MouseEvent.CLICK, onCami);



      function onCami(e:MouseEvent) {

      gotoAndPlay(1, "Scene 4");




      lily_btn.addEventListener(MouseEvent.CLICK, onLily);



      function onLily(e:MouseEvent) {

      gotoAndPlay(1, "Scene 5");




      poppy_btn.addEventListener(MouseEvent.CLICK, onPoppy);



      function onPoppy(e:MouseEvent) {

      gotoAndPlay(1, "Scene 6");


        • 1. Re: How to make buttons work within all scenes?
          Colin Holgate MVP & Adobe Community Professional

          When you go to another scene it's as if it's a new button, that doesn't have the mouse listener. If you were using a movieclip instead of a button you could put the script inside the movieclip. It would be wise to add the listener when the movieclip is added to the stage, and remove the listener when it's removed.


          There is a different way you could work though. You could name your buttons and scenes the same. Then in the intro scene you could have a script like this:


          import flash.events.MouseEvent;



          function clicked(e:MouseEvent){




          Now you can copy the four buttons, that might be named tulip, rose, lily, poppy, and clicking on any of them would take you to the scene with the same name.