1

私がこのエラーを受け取り、同様のトピックを持つ以前のすべての投稿で説明されている他の方法では解決できなかったのを助けてください。

実際、ここで私はswfmyMapを別のswfにロードしています。swfの読み込みは正常に機能しますが、これをステージから削除しようとすると、上記のエラーが発生します...

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
    at flash.display::DisplayObjectContainer/removeChild()
    at actions.classes::MapInteractionManager/unloadSWF()
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()

これが私のas3コードです...

 var _swfLoader:Loader;
    var _swfContent:MovieClip;

    loadSWF("myMap.swf");  //loading the swf file here

    function loadSWF(path:String):void {
       var _req:URLRequest = new URLRequest();
       _req.url = path;

       _swfLoader = new Loader();
       setupListeners(_swfLoader.contentLoaderInfo);

       _swfLoader.load(_req);
    }

    function setupListeners(dispatcher:IEventDispatcher):void {
       dispatcher.addEventListener(Event.COMPLETE, addSWF);
       dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
    }

    function preloadSWF(event:ProgressEvent):void {
       var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
       // swfPreloader.percentTF.text = _perc + "%";
    }

    function addSWF(event:Event):void {
       event.target.removeEventListener(Event.COMPLETE, addSWF);
       event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);

       _swfContent = event.target.content;
       _swfContent.addEventListener("close", unloadSWF);

       main.stage.addChild(_swfContent);
    }

    function unloadSWF(event:Event):void {
       _swfLoader.unloadAndStop();

    main.stage.removeChild(_swfContent);  //getting error when trying to remove swf
       _swfContent = null;
    }


    and close event is as,
    _swfContent.dispatchEvent(new Event("close"));

助けてください、私は立ち往生しています。

ここでいくつかの更新を行い、コードを次のように更新しました、

function unloadSWF(event:Event):void
{
     if(main.stage.contains(_swfContent))
           main.stage.removeChild(_swfContent);
}

ifループに入っていないため、エラーはなくなりました!!! ???

しかし、それでも私はステージ上でそのswfを見ることができます:( plz help

解決しました...助けてくれてありがとう...

ToddBFisherはそれを解決しました:)

_swfContentを使用する代わりに、_swfLoaderをステージに追加してロードし、それに近いリスナーをアタッチするだけです。真ん中の人を切り取って、それはうまくいきました....これが役立つことを願っています...

4

3 に答える 3

1

As I recall .unloadAndStop(); does a bunch of cleanup type things, which you are calling right before. It is possible part of the cleanup is removing it from the display list.

Try calling the removeChild() before calling unlodaAndStop()

function unloadSWF(event:Event):void {
    stage.removeChild(_swfContent);  //getting error when trying to remove swf
    _swfLoader.unloadAndStop();
    _swfContent = null;
}

EDIT

Try simply adding the _swfLoader to the stage, load it, and attach the close listener to it instead of even having a _swfContent. Cut out the middle man and see what happens.

于 2013-01-17T06:09:33.067 に答える
0

エラーは、子がすでに削除されている(または追加されていない)ことを意味し、コメントアウトしようとします

_swfLoader.unloadAndStop();

それが機能するかどうかを確認します。

于 2013-01-17T06:08:08.117 に答える
0

main.stage.removeChildが起動されたため、はすでに _swfContentnullに設定されているremoveChildため、行_を削除するswfContent = nullと解決する可能性があります。

于 2013-01-17T06:26:45.943 に答える