Hi, recently I'm working on a project to parse and show the VAST3 ad. One thing I need to do is listen for the MouseEvent.CLICK on the loaded SWF file.
I added the loader to a sprite and add the event listener on the sprite. When I load the following SWF file, the click event fires only when I click the background. If I click on the site logo, no click event happens.
If I downloaded the SWF file to my local hard drive, everything works fine. The click event can be fired wherever I click on the ad.
The SWF that I load has all the assets embedded.
I want to find out what's causing this problem because with some SWF files I can only listen to the MouseEvent.CLICK event on the _loader.content whereas some like the one below, partially responds to click event on _loader.content and _container.
I simplified the code as listed below.
package { import flash.display.Loader; import flash.display.Sprite; import flash.events.MouseEvent; import flash.events.Event; import flash.net.URLRequest; public class Main extends Sprite { private var _container:Sprite; private var _loader:Loader; public function Main() { _container = new Sprite(); _loader = new Loader(); _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); _loader.load(new URLRequest("http://gtms04.alicdn.com/tps/i4/TB1Fzd.FVXXXXaOXXXXeflbFXXX.swf")); _container.addEventListener(MouseEvent.CLICK, onClicked); addChild(_container); } private function onComplete(event:Event):void { _container.addChild(_loader); _loader.content.addEventListener(MouseEvent.CLICK, loadedSwfClicked); } private function loadedSwfClicked(event:MouseEvent):void { trace("loaded swf clicked"); // When I click on the Logo and the animal } private function onClicked(event:MouseEvent):void { trace("clicked"); // When I click on the gradient background } } }