DoubleClick Studio AS3 API Reference

class com.google.ads.studio.localconnect.LocalConnectWrapper

Extends com.google.ads.studio:EnabledComponent

The Local Connect component creates a bi-directional data connection to other Local Connect components running on the same client machine, so that multiple assets can communicate with each other.

For more information, see the Local Connect component.

Send data to connected components:
   // Setup: localConnectComponent is the instance name of the
   // Local Connect component on the stage.
   import com.google.ads.studio.localconnect.LocalConnectParent;
   import com.google.ads.studio.localconnect.LocalConnectWrapper;
    
   var dataObject:Object = {message: "Start synced animation!"};
    
   // Send data to all connected components.
   localConnectComponent.sendData(dataObject);
   // Send data to parent (from a child).
   localConnectComponent.sendData(
       dataObject,
       LocalConnectParent.PARENT_NAME);
   // Send data to a specific child.
   localConnectComponent.sendData(dataObject, "child");
   
Set up listeners to handle sent data:
   import com.google.ads.studio.events.StudioEvent;
   import com.google.ads.studio.localconnect.LocalConnectParent;
    
   var dataHandler:Function = function(event:StudioEvent):void {
       trace("Message was " + event.data.message);
       // If the dataObject referred to in the above "send" example is sent,
       // event.data.message will be "Start synced animation!".
       if (event.sender == LocalConnectParent.PARENT_NAME &&
           event.data.message == "Start synced animation!") {
         trace("Message was sent from the parent");
         // Start your synced animation here.
       }
   };
    
   localConnectComponent.addEventListener(
       StudioEvent.DATA_RECEIVED,
       dataHandler);
   
You may also instantiate the components programmatically:
   // Creating a parent.
   import com.google.ads.studio.localconnect.LocalConnectParent;
    
   var childChannelNames:Array = ["my child"];
   var parentConnect:LocalConnectParent =
       new LocalConnectParent(childChannelNames);
   parentConnect.connect();
    
   // Creating a child.
   import com.google.ads.studio.localconnect.LocalConnectChild;
    
   var childConnect:LocalConnectChild = new LocalConnectChild("my child");
   childConnect.connect();
   

Expand Events

Constructors

LocalConnectWrapper() : void

Creates a LocalConnectWrapper.

Instance Methods

Defined in: com.google.ads.studio:EnabledComponent

getEnabler() : Object
isInitialized() : Boolean

Returns whether the component has initialized.

Defined in com.google.ads.studio.localconnect:LocalConnectWrapper

close() : void

Closes all connections.

     lcComponentInstance.close();
     

Expand
sendData(data:Object, target:String=null) : void

Sends data to one or more other Local Connect components.

     import com.google.ads.studio.localconnect.LocalConnectParent;
     import com.google.ads.studio.localconnect.LocalConnectWrapper;
      
     var sendClickHandler:Function = function(event:MouseEvent):void {
       var dataObject:Object = {message: "Hello World!"};
       // Send data to all connected components.
       lcComponentInstance.sendData(dataObject);
       // Send data to parent (from a child).
       lcComponentInstance.sendData(
           dataObject,
           LocalConnectParent.PARENT_NAME);
       // Send data to a specific child.
       lcComponentInstance.sendData(dataObject, "lc_child");
     };
     sendButton.addEventListener(MouseEvent.CLICK, sendClickHandler);
     

Back to top

  1. com.google.ads.studio
    1. AssetLoader
    2. ContextualDiscovery
    3. F2fEnabler
    4. FullScreenButton
    5. HtmlEnabler
    6. ProxyEnabler
    7. VpaidEnabler
  1. com.google.ads.studio.configurable
    1. Configurable
  1. com.google.ads.studio.display
    1. StudioLoader
  1. com.google.ads.studio.events
    1. StudioEvent
    2. StudioVideoEvent
  1. com.google.ads.studio.expanding
    1. Expanding
  1. com.google.ads.studio.localconnect
    1. LocalConnectWrapper
  1. com.google.ads.studio.video
    1. ConfigurableVideoPlayer
    2. EnhancedVideoController
    3. PlayPauseButton
    4. Playlist
    5. Scrubber
    6. SoundToggleButton
    7. VideoController
    8. VideoEntry
    9. VideoPlayer
    10. VideoPlayerAdvanced
  1. com.google.ads.studio.vpaid
    1. VpaidTimer