New Buttons in AS3
OK, so if you’re working in Actionscript 3 then you’ve realized that making a button function is a totally different story now.
First, you CANNOT put code directly onto a button anymore. Like this:
on (release)
{
nextScene();
}
Nor can you call it by name and tag “onRelease” to the end of it.Like this:
quit_btn.onRelease = function()
{
trace(“you just released the quit button”);
}
This is the ONLY way to make a button work in AS3:
quit_btn.addEventListener(MouseEvent.MOUSE_UP, scrollUp);
i just added a function that listens for a mouse up event. when the mouse is released it will call the function called scrollUp.
Listeners have taken over AS3 so i suggest you get used to using listeners. Audio, video, and loading all use listeners in AS3.
About this entry
You’re currently reading “New Buttons in AS3,” an entry on Gena's Blurb
- Published:
- January 7, 2008 / 2:29 pm
- Category:
- Actionscript 3.0, Buttons, flash cs3
- Tags:
- actionscript3, as3, button code, buttons, event listener, flash cs3, listeners
9 Comments
Jump to comment form | comment rss [?] | trackback uri [?]