Followers

Friday, April 24, 2015

Flash: Buttons and Scenes Code

Below is code to make your buttons work with scenes.
To read more about it go here
http://www.myglife.org/usa/eaprepmlk/index.php/Help:Ingredients_-_Buttons


Draw 4 buttons on Scene 1.
Each button should have an instant name of nextButton1, nextButton2, and so on.
Make 4 scenes.
Copy the buttons to all of your scenes.
Now copy the code and put it on Scnene 1.
Test.

Here is the code...


stop();
 
import flash.events.MouseEvent;
import flash.ui.Mouse;
 
addEventListener(MouseEvent.CLICK, onMouseClick);
 
function onMouseClick(evt:MouseEvent)
{
 if(evt.target.name == "nextButton1")
 {
  gotoAndStop(1, "Scene 1");
 }
        if(evt.target.name == "nextButton2")
 {
  gotoAndStop(1, "Scene 2");
 }
      if(evt.target.name == "nextButton3")
 {
  gotoAndStop(1, "Scene 3");
 }
    if(evt.target.name == "nextButton4")
 {
  gotoAndStop(1, "Scene 4");
 }
}

No comments:

Post a Comment