AS3事件 - 类型强制失败了吗? [英] as3 Events - Type Coercion failed?
本文介绍了AS3事件 - 类型强制失败了吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我派遣从子事件到父SWF。它工作正常,直到我用了preloader SWF加载父,然后父停止获取从孩子的事件。现在我得到这个错误:
I am dispatching events from a child to a parent swf. It was working properly, until I used a preloader swf to load the parent, then the parent stopped getting events from the child. I get this error now:
TypeError: Error #1034: Type Coercion failed: cannot convert com.company.events::MyCustomEvent@22494251 to com.company.events.MyCustomEvent.
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
这是什么意思?为什么它只是发生在我包装在一个装载机主SWF?感谢您的帮助 - 我绝望
What does that mean? And why does it only happen when I wrap the main swf in a loader? Thanks for any help - I'm desperate!
推荐答案
听起来像是一个ApplicationDomain的问题。
Sounds like an ApplicationDomain issue.
尝试是这样的:
public function loadSWF(url:String):void
{
var req:URLRequest = new URLRequest(url);
var cxt:LoaderContext = new LoaderContext();
cxt.applicationDomain = ApplicationDomain.currentDomain;
var ldr:Loader = new Loader();
ldr.load(req, cxt);
}
这篇关于AS3事件 - 类型强制失败了吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文