00:00
00:00
Newgrounds Background Image Theme

UmanaJose just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

As3: Simple Navigation Button!

3,182 Views | 3 Replies
New Topic Respond to this Topic

As3: Simple Navigation Button! 2012-03-30 11:48:51


This is a tutorial to help support As3:Main ! Here is the step-by-step tutorial!

1. Open Adobe Flash
2. Click on Actionscript 3.0 under the "Create New" branch
3. Create the graphic for your button
4. Select the entire thing and right-click then select "Convert to Symbol..."
5. Put anything for the name (for now I will call this button1)
6. Register the point in the middle
7. Make sure the type is Button.
8. Give button1 the instance name of anything!(we will refer to it from now on as "Btn1")
9. Make a new layer and name it Actions
10. Go to the actions panel (Window/Actions)
11. Type the following

import flash.events.MouseEvent;

Btn1.addEventListener(MouseEvent.Event, anythinghere);

function anythinghere(event:MouseEvent):void{
	gotoAndPlay(2);
}

12. Add a blank keyframe
13. go to the actions layer and on both frame add this to the coding:

stop();

14. Test the move (ctrl + enter)
15. You have a working button! Hope I could help!

As3: Simple Navigation Button!


Current Trophies:

Weekly Fourth Place for Blast the Bunny 2

~SketchistGames :P

Response to As3: Simple Navigation Button! 2012-03-30 12:01:24


You didn't really explain what the code you posted does or why it needs to written the way it is. It is catastrophic to provide copy-paste-ready code in tutorials, where the user would just copy and paste this snippet without really knowing what it does and never really learning anything.

You should offer more explanation about mouse events, but events are covered generally by MSGHero's tutorial here.

Response to As3: Simple Navigation Button! 2012-03-30 12:27:13


Also you don't really need to import any events while coding in timelines. When in the tutorials they type the import things in the beginning is just to tell you what classes you will have to import while coding in classes.

Response to As3: Simple Navigation Button! 2012-03-30 14:34:34


And another point, for naming your instances, it's a better practice to start with a lower case, since classes typically start with an upper case.

myButton (instance name) as apposed to MyButton (class name)