In the good old days of AS2, if you needed to create a banner for click tracking, all you had to do was tto palce this simple two line AS code in the first frame of your banner after creating a button MovieClip and that would do the job.
box_mc.onRelease = function (){ getURL(_level0.clickTag, "_blank"); };
But no more in ActionScript3. In AS3, code is a bit complex and longer. Using AS3, you just can’t use the un-declared and un-caught variable clickTag in your script. First you have to get it usingLoaderInfo parameters
In the second step, you need to create the button MovieClip and add its EventListener for click. Now pass the clickTAG variable to flash.net.navigateToURL and that would open the window.
Here’s the complete AS3 code:
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters; var clickTAG:String = String(paramObj["clickTAG"]); box_mc.addEventListener( MouseEvent.CLICK, openBanner); function openBanner(event: MouseEvent) : void { flash.net.navigateToURL(new URLRequest( clickTAG ), "_blank"); } box_mc.buttonMode = true; box_mc.useHandCursor = true;
I have put together this CS4 .fla file. You may download this demo as3-clickTag-banner CS4 .fla file to check the functional banner.
Hope that helps.
Cheers!