Skip to content
June 25, 2012 / Danii Oliver

Action Script 3 clicktag-

Action Script 3 – Banner Ad Dynamic clickthrough functionality.

function handleClick(mouseEvent:MouseEvent):void {

var interactiveObject:InteractiveObject = mouseEvent.target as InteractiveObject;

var li:LoaderInfo = LoaderInfo(interactiveObject.root.loaderInfo);

var url:String = li.parameters.clicktag;

if (url) {

if (ExternalInterface.available) {

var userAgent:String = ExternalInterface.call(‘function(){ return navigator.userAgent; }’);

if (userAgent.indexOf(“MSIE”) >= 0) {

ExternalInterface.call(‘window.open’, url, ‘_blank’);

} else {

navigateToURL(new URLRequest(url), ‘_blank’);

}

} else {

navigateToURL(new URLRequest(url), ‘_blank’);

}

}

}

myButton_btn.addEventListener(MouseEvent.MOUSE_UP,handleClick);
Requirements

For this clicktag to work in all browsers the following two requirements need to be met:

  • The html object tag needs an id or Internet Explorer will generate a javascript error of “null is null or not an object”.
  • AllowScriptAccess needs to be true either by setting it to “always” or by setting it to “sameDomain” and loading the flash from the same domain as the hosting page.
Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s