我只是将动画片段从装载机移到舞台上。
但是当我尝试移动或旋转动画片段时,我遇到了错误“#2025”。
错误#2025:提供的DisplayObject必须是调用者的子级
我的代码出了什么问题?
[主要家长MC]
function loaderShow(url:String):void{
var urlRequest:URLRequest = new URLRequest(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loader_complete);
loader.load(urlRequest);
addChild(loader);
}
function loaderClose():void{
loader.unload();
removeChild(loader);
}
function loader_complete(evt:Event):void {
var target_mc:Loader = evt.currentTarget.loader as Loader;
target_mc.x = (stage.stageWidth - target_mc.width) / 2;
target_mc.y = (stage.stageHeight - target_mc.height) / 2;
}
function addTextEmoticon(ty:int, target:DisplayObject):void{
var mc:MovieClip = target as MovieClip;
addChild(mc);
mc.x = 10; // error occured #2025
mc.y =20; // error occured #2025
}
[儿童MC - 装载机]
function clickHandler(e:MouseEvent):void{
var mc:MovieClip = e.currentTarget as MovieClip;
root_movie.addTextEmoticon(1, mc);
root_movie.loaderClose();
}