From September, Flash will no longer be supported by Chrome. Prepare for the shift towards HTML5 by visiting our Flash to HTML5 help page

Check it out!

Adform In-Screen Class

AdformInScreen class is designed to easily track banner in-screen parameters (e.g. when banner is visible on a webpage). The class is supported in both the ActionScript 2 and ActionScript 3 versions and is installed together with the Adform Creative Toolkit.

  • Dependencies

    In order to use the in-screen class in the ActionScript 3 banner, Adform Core component must be placed on the stage. Otherwise, methods or listeners will not work.

  • Public Methods

    addEventListener()
    ActionScript 2:

    public static function addEventListener(type:String, listener:Function):Void

    ActionScript 3:

    public static function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void

    Adds an event listener object to the EventDispatcher object in order for the listener to receive a notification of an event.

    Parameters

    type:String - type of event.
    listener:Function - listener function that processes the event. This function must accept the Event object as its only parameter, and return nothing (as it is showed in in the following example):

    function(evt:Event):void
    

    The function can have any name.

    useCapture:Boolean (default = false) - determines whether the listener works in the capture phase, or in the target and bubbling phases. If useCapture is set to "true", the listener processes the event only during the capture phase, and not in the target or bubbling phases. If useCapture is "false", the listener processes the event only during the target or bubbling phase. In order to process the event in the all three phases, call the addEventListener twice: once with useCapture set to "true", then again with useCapture set to "false".

    prioritY:int (default = 0) - the priority level of the event listener. The priority is designated by a signed 32-bit integer. The higher the number is, the higher is the priority. All listeners with the priority "n" are processed before listeners with priority "n-1". If two or more listeners share the same priority, they are processed in the order in which they were added. The default priority is 0.

    useWeakReference:Boolean (default = false) - determines whether the reference to the listener is strong or weak. A strong reference (by default) prevents the listener from being garbage-collected, while a weak reference does not.

    As class-level member functions are not subject to the garbage collection, you can set useWeakReference to "true" for the class-level member functions without subjecting them to the garbage collection. If useWeakReference is set to "true" for a listener that is a nested inner function, the function will be garbage-collected and no longer persistent. If references are created for the inner function (saved in another variable), then it is not garbage-collected and stays persistent.

     

    removeEventListener()
    ActionScript 2:

    public static function removeEventListener(type:String, listener:Function):Void

    ActionScript 3:

    public static function removeEventListener(type:String, listener:Function, useCapture:Boolean =false):void

    Removes a listener from the EventDispatcher object. If there is no matching listener registered with the EventDispatcher object, a call to this method has no effect.

    Parameters
    type:String
     - the type of event.
    listener:Function - the listener object to remove.
    useCapture:Boolean (default = false) - specifies whether the listener was registered for the capture phase, or for the target and bubbling phases. If the listener was registered for both the capture phase and the target and bubbling phases, two calls to removeEventListener() are required to remove both: one call with useCapture() set to "true", and another call with useCapture() set to "false".

     

    getValue()
    ActionScript 2/ActionScript 3

    static public function getValue(name:String):Object

    Get in-screen parameter value by a specific name.

    Parameters

    name:String - the name of the an in-screen parameter.

     

  • Events

    AdformInScreen provides only in-screen parameters' change events. Every event type constant consists of two parts: an in-screen parameter name and a word Change. For example, 'percent' + 'Change' -> 'percentChange'

    Every event object has data property. This property holds the latest In-Screen parameter value. See the examples below.

    The following event types are available at the moment:

    • 'percentChange'
    • 'visibleChange'

    In-Screen Properties:

    • percent - will return banner visibility percent from 0 to 100
    • visible - will return if banner is visible (true or false)

    Note: These properties should be used in method: AdformInScreen.getValue()

     

     

  • Examples

    ActionScript 2 example:

    AdformInScreen.addEventListener('percentChange', hanldePercentChange);
    AdformInScreen.addEventListener('visibleChange', hanldeVisibleChange);
    setTimeout(checkData, 2500);
    
    function hanldePercentChange(e:Object):Void {
        trace(e.data); // latest percent number
    }
    
    function hanldeVisibleChange(e:Object):Void {
        trace(e.data); // latest banner visible
    }
    
    function checkData():Void {
        trace(AdformInScreen.getValue('percent'));
        trace(AdformInScreen.getValue('visible'));
    }

    ActionScript 3 example:

    AdformInScreen.addEventListener('percentChange', hanldePercentChange);
    AdformInScreen.addEventListener('visibleChange', hanldeVisibleChange);
    setTimeout(checkData, 2500);
    
    function hanldePercentChange(e:Object):void {
        trace(e.data); // latest percent number
    }
    
    function hanldeVisibleChange(e:Object):void {
        trace(e.data); // latest banner visible
    }
    
    function checkData():void {
        trace(AdformInScreen.getValue('percent'));
        trace(AdformInScreen.getValue('visible'));
    }