ActionScript 3.0 Click Button Code Example

Here is an example on coding for click button in ActionScript 3.0. The example below, there are 2 buttons are careted in the flash.

Here is an example on coding for click button in ActionScript 3.0. The example below, there are 2 buttons careted in the flash. One is named as btnReplay and another one is myButton


var clickTAG = root.loaderInfo.parameters.clickTAG;
myButton.addEventListener("click", onClick);
btnReplay.addEventListener("click", replay);

function onClick(evt:MouseEvent):void {
	// comment out for testing
	// trace("you clicked me"); 

	// embedded with a static URL or...
	// var targetURL:URLRequest = new URLRequest("http://yourURL.com/");
	//navigateToURL(targetURL);

	// when URL is a flash var use this
	var targetURL:URLRequest = new URLRequest(clickTAG);
	navigateToURL(targetURL);
}
function replay(evt:MouseEvent):void {
	gotoAndPlay("start");
}

Then, in html codes, add a flash var to access the above flash.

animation.swf?clickTAG=http://yourURL.com

Flash example below is adding with “?clickTAG=http://www.wishingkits.com” in the source.


ActionScript 3.0 Click Button Code Example

Tagged with:
 

Comments are closed.



Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...