Search code examples
actionscript-3flashdouble-click-advertising

Loading external SWF files with AS3 for google DoubleClick


I've a rich media creative that I'm trying to submit to google DoubleClick. The parent swf plays a short loop that when clicked, should reveal the second swf, which is an emebedded youtube video.

Doubleclick supply the following code snipped to achieve this:

import com.google.ads.studio.HtmlEnabler;
import com.google.ads.studio.events.StudioEvent;
import com.google.ads.studio.display.StudioLoader;

var enabler:HtmlEnabler = HtmlEnabler.getInstance();
enabler.init(this);

function pageloadHandler(event:StudioEvent):void {
  var mySwfLoader:StudioLoader = new StudioLoader();
  var request:URLRequest = new URLRequest("as3_child.swf");
  mySwfLoader.load(request);
  holderMC.addChild(mySwfLoader);
}
enabler.addEventListener(StudioEvent.PAGE_LOADED, pageloadHandler);

ref: https://support.google.com/richmedia/answer/2717077?hl=en

When I add this to the first frame of my parent flash file I get the error:

Scene 1, Layer 'Layer 7', Frame 1, Line 12  1120: Access of undefined property holderMC.

holderMC is given supplied with the google snipped, and not referenced anywhere else, so I'm unsure if I'm missing something obvious, or if there's something omitted from the snipped. I'm very new to AS3, so apologies if this is explained poorly.

Thanks,


Solution

  • holderMC sounds like a generic name for a MovieClip. I'm pretty sure that should be a reference to a mc in your parent swf.

    "You must instantiate the StudioLoader, mySwfLoader, and URLRequest. Then load in the path of the image, as3_child.swf, through the StudioLoader’s load method."

    You also have to add the loader to a parent so the loaded content can be shown. That's what holderMC.addChild(mySwfLoader); should stand for.