The ONE by AOL: Creative API

The below methods are interchangeable between both our AS3 and Javascript APIs. The Core libraries in both Flash and Javascript are merely bridges between the ad and our javascript library which renders the ad to the page.


ADTECH.event('name')

Use this to track events with the name ‘name’. This is most commonly used to track user interactions with the ad. Here’s an example of some AS3 code to track a click on a play game button within a flash ad:


playButton.addEventListener(MouseEvent.CLICK, playButtonClickHandler)
function playButtonClickHandler(event:MouseEvent) : void {
ADTECH.event('Play Game');
}

Once the file has been uploaded to ONE by AOL: Creative, the ‘name’ will be visible and editable in the events panel.


ADTECH.click('name'[, 'defaultURL'])

This opens a new window with the URL matching the one defined in the clicks panel with the corresponding name. If the optional defaultURL is specified, this will be used by ONE by AOL: Creative by default but can be changed. All clickthroughs should use this method as it ensures that the clickthroughs are tracked and reported against. Use of getURL or other clickthrough methods is strictly forbidden. Here’s an example of some AS3 code to track a clickthrough to the ONE by AOL homepage.

clickButton.addEventListener(MouseEvent.CLICK, clickButtonClickHandler)
function clickButtonClickHandler(event:MouseEvent) : void {
  ADTECH.click("ONE by AOL Home", "http://www.onebyaol.com");
}
 

ADTECH.dynamicClick('name', 'url')

This opens a new window with the URL matching the required ‘url’ parameter. You should use this method if you want to dynamically construct the url in the flash movie and don’t want it to be overridden in the ONE by AOL: Creative UI. The click will tracked and reported under the supplied name. Here’s an example of some AS3 code to track a clickthrough to a dynamic url using a variable defined elsewhere in the code:

clickButton.addEventListener(MouseEvent.CLICK, clickButtonClickHandler)
function clickButtonClickHandler(event:MouseEvent) : void {
 ADTECH.dynamicClick("Product page", "http://www.mysite.com/products?id=" + product_id );
}
 

ADTECH.getFileUrl('fileName')

This method should be used to wrap all additional file names that your Flash movie loads in. It is discussed in detail here. It should be implemented when any external asset loading Flash APIs are used such as Sound.loadSound, loadMovieNum and MovieClipLoader.loadClip. Here’s an example of some AS3 code that uses this method:

var loader = new Loader();
loader.contentLoaderInfor.addEventListener(Event.COMPLETE, loadCompleteHandler);
loader.load(new URLRequest(ADTECH.getFileUrl('additionalMovie.swf')));
 

ADTECH.getFileUrlById('id',['defaultFileName'] )

This can be used as an alternative to ADTECH.getFileUrl(). It allows you to specify different files to be loaded in for the specified id within the ONE by AOL: Creative UI and is discussed in more detail here. Here’s an example of some AS3 code that uses this method:

var loader = new Loader();
loader.contentLoaderInfor.addEventListener(Event.COMPLETE, loadCompleteHandler);
loader.load(new URLRequest(ADTECH.getFileUrlById('secondMovie','additionalMovie.swf')));
 

ADTECH.addEventListener('type', listenerFunction)

This registers a function to be invoked when the event with type ‘type’ has been dispatched from our Component. Standard event types include ADTECH.EVENT_MOUSE_OVER, ADTECH.EVENT_MOUSE_OUT and ADTECH.EVENT_PAGE_LOAD. Here’s an example of some AS3 code that listens for the page load event and then loads in an additional movie (common functionality for polite load ads):

function pageloadedHandler(event:Event) : void{
var loader = new Loader();
loader.contentLoaderInfor.addEventListener(Event.COMPLETE, loadCompleteHandler);
loader.load(new URLRequest(ADTECH.getFileUrl('additionalMovie.swf')))
 // It's good practice to remove the event listener if it's not required anymore.
 ADTECH.removeEventListener(ADTECH.EVENT_PAGE_LOADED, pageloadedHandler);
}
ADTECH.addEventListener(ADTECH.EVENT_PAGE_LOADED, pageloadedHandler);
 

ADTECH.removeEventListener('type', listenerFunction)

This de-registers a function from being invoked when the event with type ‘type’ has been dispatched from our Component. Examples of it’s usage can be seen above and below:

ADTECH.removeEventListener(ADTECH.EVENT_MOUSE_OVER, myMouseOverHandler);
 

ADTECH.expand()

A call to the ADTECH.expand() function tells the Javascript to expand the containing content layer so that the expanded section of the flash movie can be seen. You should therefore call the ADTECH.expand() function as soon as any of the flash content spills over the contracted area. This is discussed in more detail here. Here’s an example of some AS3 code that listens for the mouse over event and then calls the ADTECH.expand() event before instructing the flash movie to begin it’s animation:

function myExpandFunction(event:Event) : void {
 ADTECH.expand();
 goToAndPlay(10);
 ADTECH.removeEventListener(ADTECH.EVENT_MOUSE_OVER, myExpandFunction);
}
ADTECH.addEventListener(ADTECH.EVENT_MOUSE_OVER, myExpandFunction);
 

ADTECH.contract()

A call to the ADTECH.contract() function tells the Javascript to return the containing content layer to it’s contracted state. You should call the ADTECH.contract() function as soon as all of your ad content is back contained within the contracted area. This is discussed in more detail here

Here’s an example of some AS3 code that listens for the mouse out event and then calls the ADTECH.contract() event:

function myContractFunction(event:Event) : void {
 goToAndStop(1);
 ADTECH.contract();
 ADTECH.removeEventListener(ADTECH.EVENT_MOUSE_OUT, myContractFunction);
}
ADTECH.addEventListener(ADTECH.EVENT_MOUSE_OUT, myContractFunction);
 

ADTECH.close()

A call to the ADTECH.close() function tells the Javascript to hide and completely remove the containing content layer. This is typically used on a close button on an Overlay or Floating ad. It should be used when the content will not be shown again. Here’s an example of AS3 code that could be placed on a close button:


closeButton.addEventListener(MouseEvent.CLICK, closeButtonClickHandler); 
function closeButtonClickHandler(){ 
  ADTECH.close(); 
}

ADTECH.hide()

A call to the ADTECH.hide() function tells the Javascript to hide (but not remove) the floating content layer. This should be used to hide the Overlay or Floating part of an ad when it is possible that the Overlay or Floating part will be shown again (eg. an ADTECH.show() event is subsequently called). It is typically used on the close button in an In-Page & Overlay, In-Page & Floating, Slider and Sidekick ad. Here’s an example of AS3 code that could be placed on a close button:

hideButton.addEventListener(MouseEvent.CLICK, hideButtonClickHandler);
function hideButtonClickHandler(){
  ADTECH.hide();
}
 

ADTECH.show()

A call to the ADTECH.show() function tells the Javascript to show a floating content layer. This should be used to show the Overlay or Floating part of an ad. It is also used to show the Sidekick and Slider Content parts of the Sidekick and Slider formats. It is typically used on a button within one Flash movie to display the content of another Flash movie. Here’s an example of AS3 code that could be placed on the button:

showButton.addEventListener(MouseEvent.CLICK, showButtonClickHandler);
function showButtonClickHandler(){
  ADTECH.show();
}

Please note that this function will not reload the flash movie in the floating content layer. If you want the floating part of the format to reload (i.e starts playing from the beginning again), use the ADTECH.reload() method discussed below.

 

ADTECH.reload()

A call to the ADTECH.reload() function tells the Javascript to show AND RELOAD the contents a floating content layer. This should be used to reload/replay the Overlay or Floating part of an ad. It is also used to reload/replay the Sidekick and Slider Content parts of the Sidekick and Slider formats. It is typically used on a button within one Flash movie to replay the content of another Flash movie in another layer. Here’s an example of AS3 code that could be placed on the button:

reloadButton.addEventListener(MouseEvent.CLICK, reloadButtonClickHandler);
function reloadButtonClickHandler(){
  ADTECH.reload();
}

For more information please view our Code Libraries documentation here.

Feedback and Knowledge Base