flash AS3 - 参数子项必须为非空
出现错误
类型错误:错误#2007:参数 孩子必须是非空的。在 flash.display::DisplayObjectContainer/addChildAt() 在 fl.controls::ProgressBar/drawTrack() 在 fl.controls::ProgressBar/draw() 在 fl.core::UIComponent/callLaterDispatcher()
,任何想法。谢谢。动画导入正常,但我在没有显示进度条的情况下收到该错误。
import fl.controls.ProgressBar;
var swfRequest:URLRequest = new URLRequest("animation2.swf"); //load animation file
var swfLoader:Loader = new Loader();
var progressBarr:ProgressBar = new ProgressBar();
progressBarr.source = swfLoader.contentLoaderInfo;
progressBarr.x = 27;
progressBarr.y = 155;
loadMovie();
function loadMovie():void{
addChild(progressBarr);
swfLoader.load(swfRequest);
}
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded, false, 0, true); //when loaded call swfLoaded
//swfLoader.load(swfRequest);
//
function swfLoaded(event:Event):void{
swfMC.addChild(swfLoader); //add animation to swfMC movie clip
removeChild(progressBarr);
}
stop();
getting error
TypeError: Error #2007: Parameter
child must be non-null. at
flash.display::DisplayObjectContainer/addChildAt()
at
fl.controls::ProgressBar/drawTrack()
at fl.controls::ProgressBar/draw()
at
fl.core::UIComponent/callLaterDispatcher()
within cs5, any ideas. thanks. The animation imports fine, but I am getting that error without the progress bar being shown.
import fl.controls.ProgressBar;
var swfRequest:URLRequest = new URLRequest("animation2.swf"); //load animation file
var swfLoader:Loader = new Loader();
var progressBarr:ProgressBar = new ProgressBar();
progressBarr.source = swfLoader.contentLoaderInfo;
progressBarr.x = 27;
progressBarr.y = 155;
loadMovie();
function loadMovie():void{
addChild(progressBarr);
swfLoader.load(swfRequest);
}
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded, false, 0, true); //when loaded call swfLoaded
//swfLoader.load(swfRequest);
//
function swfLoaded(event:Event):void{
swfMC.addChild(swfLoader); //add animation to swfMC movie clip
removeChild(progressBarr);
}
stop();
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 CS5 中,没有给我任何错误,尽管您可以检查的一件事是,从组件窗口拖动进度条组件,保存并运行文件,然后删除实例。之后你的代码应该可以正常工作。
您也可以将此行注释为:
在此处检查 fla:
http://ashwani.50webs.com/test.fla
giving no errors to me, in CS5, though one thing that you can check is, drag a progress bar component from the component window, save and run your file, then delete the instance. after that your code should do just fine.
also you can comment this line as:
check fla here:
http://ashwani.50webs.com/test.fla
尝试调用
您是否在初始化加载程序后 ?您可能需要等到实例化后才能将任何内容分配给其 contentLoaderInfo。因此,将其从顶部删除并将其添加到 swfLoader.load 调用下方:
Did you try calling
after you intialized the loader? You may need to wait until that has been instantiated before assigning anything to its contentLoaderInfo. So, remove it up at the top and add it below the swfLoader.load call: