【发布时间】:2015-09-29 07:38:00
【问题描述】:
好的,我有一个使用 Loader 对象在子 swf 中加载的 Flash 浏览器应用程序。我认为向 Loader 对象添加鼠标单击侦听器可以让我侦听对象上的点击,但事实并非如此。 :/
我确实看到了点击!!!当我在我的 IDE (Flash Develop) 中进行测试时被追踪。但是,当放入任何浏览器时,鼠标处理程序永远不会被调用。有谁知道为什么会发生这种情况?
此外,尝试访问加载器对象的子对象会导致安全沙箱错误。
public function Main()
{
trace("Starting...");
Security.allowDomain('*');
Security.allowInsecureDomain('*');
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
var inputFlashVars:Object = this.loaderInfo.parameters
_swfLoader = new Loader();
stage.addChild(_swfLoader);
_swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSwfLoaded);
var ldrContext:LoaderContext = new LoaderContext(true);
ldrContext.checkPolicyFile = true;
ldrContext.applicationDomain = new ApplicationDomain(ApplicationDomain.currentDomain);
//ldrContext.applicationDomain = new ApplicationDomain(new ApplicationDomain());
var urlForVideoToPlay:String = AD_SWF_URL;
trace("Loading swf: " + urlForVideoToPlay + " with click URL: " + CLICKTHROUGH_URL);
_swfLoader.load(new URLRequest(urlForVideoToPlay), ldrContext);
}
private function onSwfLoaded(e:Event):void
{
//var swfChild:* = _swfLoader.getChildAt(0);
//_swfLoader.mouseChildren = false;
trace(e.target);
_swfLoader.stage.addEventListener(MouseEvent.CLICK, onInnerSwfClicked, false);
_swfLoader.stage.addEventListener(MouseEvent.MOUSE_DOWN, onInnerSwfClicked, false);
_swfLoader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onSwfLoaded);
trace("Ad swf loaded!");
}
private function onInnerSwfClicked(e:Event):void
{
trace("clicked!!!");
e.stopImmediatePropagation();
}
【问题讨论】:
标签: flash actionscript-3