ClickTag in AS3
March 5th, 2010 Posted in ActionScript 3
To build a ClickTag in Flash AS3 you need to first create the ActionScript:
clickTrackBTN.buttonMode=true; //using an MC for button so I need to declare it clickTrackBTN.addEventListener(MouseEvent.CLICK,function():void { navigateToURL(new URLRequest(formatClickTag()),"_blank"); }); //the function function formatClickTag():String { for (var key:String in root.loaderInfo.parameters) { if (key.toLowerCase()=="clicktag") { return root.loaderInfo.parameters[key]; } } return ""; }
Remember to import any needed classes:
import flash.display.MovieClip; import flash.events.*; import flash.net.navigateToURL; import flash.net.URLRequest;
Then, in the HTML:
..."flashvars",'clickTAG=http://www.yourdomain.com&clickTarget=_blank', ... and <param name='flashvars' value='clickTag=http://www.yourdomain.com&clickTarget=_blank' />