Powered by SquareSpace
Powered by Squarespace
« New Site Design! | Main | maya nCloth custom tear tutorial »

ActionScript 3.0 clickTag implementation - the right way

The web is full of bad/broken examples of AS3/clickTag implementations. For one thing, Flash barfs up all sorts of junk into the HTML generated via the "Publish" command - this breaks flash embedding in some browsers. Also, many of the code examples online fail to use a proper event listener to load the flashvars data. Below is the RIGHT way to handle it:

HTML object/embed code:

<object width="550" height="400">
	<param name="movie" value="clickTagTest.swf" />
	<param name="flashvars" value="clickTag=" />
	<!-- IE embed -->
	<embed src="clickTagTest.swf" 
			type="application/x-shockwave-flash" />


//variable to store flashVars
var flashVars:Object;

// listen for a COMPLETE event to dispatch from loaderInfo
this.loaderInfo.addEventListener(Event.COMPLETE, varsLoaded);

// initialize vars and add event listener
function varsLoaded(_e:Event) {
    flashVars =;
    // add mouse click listener
    stage.addEventListener(MouseEvent.CLICK, mClick);

//open a blank browser tab and point it at the clickTag link
function mClick(_e:Event) {
    navigateToURL(new URLRequest(flashVars.clickTag), "_blank")

Additional code to handle initialization and user input will likely be required for deployment, but this method should perform consistently across all modern browsers.