Reputation: 11
Im new at actionscript 3.0 and am currently doing a flash presentation. It is all completed except for the buttons, I have no idea how to use actionscript 3.0. I have a lot of buttons but all i need is the commands to make the button (when clicked on) go to another scene and also replay the scene it is on.
Thanks
Upvotes: 0
Views: 1456
Reputation: 187
import flash.events.MouseEvent;
//use stop in the begin to avoid the repeat frames again
stop();
//here i have play button is play_mc if it click then it goes to the
function GameStart
mc.play_mc.addEventListener(MouseEvent.CLICK, GameStart);
mc.play_mc.useHandCursor = true;
mc.play_mc.buttonMode = true;
function GameStart(event:MouseEvent):void
{
//gotoAndPlay by using to go to the frame Gameplay is the frame name it
goes to that frame
gotoAndPlay("GamePlay");
}
If you want to know more go here and learn http://www.adobe.com/devnet/flash/articles/accessible_animated_preso.html
Upvotes: 0
Reputation: 2220
If you have a button on stage, let's say called button0
, then:
button0.addEventListener("click", button0Clicked);
function button0Clicked(evt:*):void
{
//do whatever you want to do here
}
There are some other events, just change click to mouseDown
, mouseUp
, doubleClick
, mouseOver
, mouseOut
. I think these types speak for themselves.
If you use doubleclick, you have to set doubleClickEnabled
to true
:
button0.doubleClickEnabled = true;
Also really useful to know:
button0.buttonMode = true;
button0.useHandCursor = true;
If button0 is not a Button instance, but a MovieClip instance and you want the mouse to turn into a "hand" when the mouse is over the button.
I hope this helps you to get closer to your goal.
Upvotes: 3