AS3 :: Button Code

Here is the basic scripting/code for buttons:
I have added comments that are preceded with double slashes – // – to help explain them.
In the Actionscript window, they appear grey, as they do here.
If your function name or instance name turns blue or green, it has a particular meaning to Flash. BEWARE!

//functions. The function names are whatever you name them.
function goFrame(e:Event):void {
      gotoAndPlay(1,“framexframe”)
};
//This will go to frame 1 of scene “framexframe”

function goBitmap1(e:Event):void {
      gotoAndPlay(1,“bitmap”)
};
//This will go to frame 1 of scene “bitmap”

//buttons. Don’t forget to name the button instances on the stage!!

framexframe_btn.addEventListener (MouseEvent.CLICK, goFrame);
//executes the goFrame function from above when the button is clicked

bitmap_btn.addEventListener (MouseEvent.CLICK, goBitmap);
//executes the goBitmap function from above
//DON’T FORGET…the code is CASE SENSITIVE!

A picture of Angela Berlingeri in a striped shirt.

About Angela

What a long, strange trip it’s been! Here’s some shameless info about me:
Bio here.
Design career details here.


Main Categories

Beautification Projects

  • Motion Graphics
  • Animations
  • Murals, Stained Glass

Music

Teaching


Search the Site: