Home arrow Web Design Blog arrow ActionScript 3.0 Click Button Code Example

ActionScript 3.0 Click Button Code Example PDF Print E-mail

There are two buttons are 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

Content on this page requires a newer version of Adobe Flash Player.

Get Adobe Flash player

 
< Prev   Next >