Linking buttons in AS 3

//Linking buttons in AS 3

Since this is just a movie for a button, make the stage 100 px by 35 px, as we don’t need any more room that that for this button.

Create a Layer, called “visuals” this is where all the visuals will go, and will be the layer for the button.

drag a button on the the stage(window>common libraries>buttons) pick any button you like, and place it on the stage that you just created. If you double click the button, you can get into the movie clip so that you can create new text on the button. In the button movie clip you will see many layers, but you want to concentrate on the text layer. On this text layer, double click on the text on the button, and change the text. This is not necessary at all, but I doubt you want your button to say “Enter.” However, there are situations for this.

Give the button an instance name “visit_btn”

The reason why you want to use this instance name is so that you can communicate the button with actionscript.

create a new layer called “actions”, this is where all your actionsctipt you go. To get to the actions panel right click on this layer, and picks actions, or go to Window>Actions

Type the following code in the actions window


visit_btn.addEventListener(MouseEvent.CLICK, visit);

function visit(e:MouseEvent):void {

	var request:URLRequest=new URLRequest("http://hfug.net");

 	navigateToURL(request, "_self");

}

Here is my completed swf

[kml_flashembed fversion=”9.0.0″ movie=”http://hfug.net/wp-content/uploads/2010/03/myButton.swf” targetclass=”flashmovie” publishmethod=”static” width=”100″ height=”35″]

Get Adobe Flash player

[/kml_flashembed]

If you are un sure about any of this, please leave a comment, so I can help you through this. This post was motivated from a friend that says linking in actionscript 3 takes too much code, but as you can see it is straight forward, and very easy.

By | 2009-02-15T03:45:51+00:00 February 15th, 2009|Flash|3 Comments

About the Author:

3 Comments

  1. Norie February 16, 2009 at 7:27 am

    Hi Johnny:) though I am not good with programs and applications. I think, any one who read it could learn a lot and applied it to get the desired output:)

  2. John Barrett February 16, 2009 at 9:28 pm

    Hi Norie, thanks so much. It is my hope that people can find the blog and start learning flash, especially the new actionscript language of AS 3!

  3. Anish December 29, 2010 at 11:15 pm

    Hi John,

    I am kind of confused on how to embed a facebook and twitter button on to my flash website. Could you please guide me?
    My website is created on AS2.

Leave A Comment