Flash – AS3 : How to insert ClickTag in Flash ActionScript 3.0 and ActionScript 2.0

Please follow & like us :)

flash-logoYou can write ClickTag in both ActionScript 3.0 (AS3) and ActionScript 2.0 (AS2).

Below is the ActionScript 3.0 code. If you name your button something other than ASClickTagButton you will have to edit this code to change the button name. Also, you should be aware that Flash 10 treats the clickTAG parameter name case sensitively.

Sample AS3 Code :

ASClickTagButton.addEventListener(
  MouseEvent.CLICK,
  function():void {
    if (root.loaderInfo.parameters.clickTAG.substr(0,5) == "http:") {
      navigateToURL(
        new URLRequest(root.loaderInfo.parameters.clickTAG), "_blank"
      );
    }
  }
);

Below is the ActionScript 2.0 code. You should be aware that Flash 8 and 9 treat the clickTAG parameter name case sensitively. Make sure to change it if your ad server requires another variation such as clickTag or ClickTag and also verify that both occurrences of the parameter name are exactly them same.

Sample AS2 code :

on (release) {
  if (_root.clickTAG.substr(0,5) == "http:") {
    getURL(_root.clickTAG, "_blank");
  }
}