我在ActionScript 3.0中导入外部SWF时遇到了一个奇怪的问题。
我想导入一个用EasyPano TourWeaver 7.96制作的SWF,但是当我这样做时,我得到Error #2007: Parameter child must be non-null.
这是代码:
var VRArea:MovieClip = new MovieClip();
VRArea.x = 0;
VRArea.y = 96;
addChild(VRArea);
var my_Loader:Loader = new Loader();
var urlRequest : URLRequest = new URLRequest("vr/vr_Candela.swf");
my_Loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loaderComplete);
my_Loader.load(urlRequest);
function loaderComplete(event:Event):void {
VRArea.addChild(my_Loader);
}
完整错误如下所示:
TypeError: Error #2007: Il valore del parametro type deve essere diverso da null.
at flash.events::EventDispatcher/addEventListener()
at `[::-V/5?()
at ->::4J/Step4_2_startUI()
at ->::4J/`Z()
at [A::&=/1?()
at [A::%c/dispatch()
at !A::%D/load()
at ->::4J/Step3_1_LoadConfig()
at ->::4J/Step3()
at ->::4J/Step2_createContext3D()
at ->::4J/%$()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at $::TWLoadingWindow/+&()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 0M::1X/;$()
at 0M::1X/3@()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at 0M::>5/&S()
其他信息:我只获得外部SWF的加载屏幕。
答案 0 :(得分:0)
您应该在侦听器中使用event.target
来添加加载器对象。此外,由于您已将侦听器分配给loaderInfo
属性,因此您需要获取作为加载了SWF的对象的对象content
。
function loaderComplete(event:Event):void {
var li:LoaderInfo=event.target as LoaderInfo;
if (!li) return; // failed typecast
VRArea.addChild(li.content); // add content
}
答案 1 :(得分:0)
我解决了这个问题:我尝试嵌入的SWF是用 Flash 11.x (至少 Flash CS6 )制作的,而我的 Flash 10.0 < / em>( Flash CS5 )。我解决了升级到 Flash CS6 并再次发布的问题。现在没事。