Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your loader technique seems the most sane. One of the benefits is, you can make it generic so that it can load any ad you want, with as many instances on the page as you need, while always yielding the same click data. This simplifies the need to capture multiple types of click data that different Flash ads sometimes produce.</p> <p>Here is some code I got working, sorry in advance for the large snippets.</p> <p><strong>ImportMe.as</strong> (has a button instance on the stage named myButton)</p> <pre><code>package { import flash.display.MovieClip; import flash.display.SimpleButton; import flash.events.MouseEvent; public class ImportMe extends MovieClip { public function ImportMe() { myButton.addEventListener(MouseEvent.CLICK, button_OnClick); } private function button_OnClick(event:MouseEvent):void { // shifts the button right 10 pixels to prove the event fired myButton.x += 10; } } } </code></pre> <p><strong>Tester.as</strong> (loads the ImportMe.swf clip generated from the previous code)</p> <pre><code>package { import flash.display.MovieClip; import flash.display.Loader; import flash.net.URLRequest; import flash.events.*; public class Tester extends MovieClip { public function Tester() { var request:URLRequest = new URLRequest("importme.swf"); var loader:Loader = new Loader(); loader.addEventListener(Event.COMPLETE, loader_OnComplete); loader.addEventListener(MouseEvent.CLICK, loader_OnClick); loader.load(request); addChild(loader); } private function loader_OnComplete(event:Event):void { trace("loaded"); } private function loader_OnClick(event:MouseEvent):void { trace("clicked"); } } } </code></pre> <p>The only thing this example doesn't test is whether or not the external event will fire before the internal clip does a url redirect.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload