0

遭遇したほとんどすべての例を試した後、私はレンガの壁にぶつかりました。ここの誰かが私を助けてくれるかもしれないと思っていました。

簡単に言えば、Flex からアクセスする必要があるメソッドを持つ Flash SWF ファイルを埋め込む Flex の親があります。

MXML:

    <mx:states>

        <mx:State name="intro">
            <mx:AddChild position="lastChild">
                <mx:SWFLoader x="285" y="170" id="introSwfLoader" source="@Embed(source='Introduction.swf')" />
            </mx:AddChild>
        </mx:State> 

SWFLoader を MovieClip として厳密に入力して制御しようとしましたが、うまくいきませんでした。

閃光:

function reset(){

    // some code
}

誰か提案はありますか?基本的に、mx:State が変更されたときに Flash SWF をリセット/リロードするだけです。

御時間ありがとうございます..

4

1 に答える 1

1

LocalConnection は必要ありません。

これを試してみてください - これは最も洗練されたソリューションではありませんが、うまくいくようです - Flex アプリのいくつかの方法で、ロードされた SWF を MovieClip として次のようにアクセスできます。

function accessLoadedSWFAsMovieClip():void{
    var container:DisplayObjectContainer = introSwfLoader.content as DisplayObjectContainer; //gets the SWFLoader content as a DisplayObjectContainer
    var loader:Loader  = container.getChildAt (0) as Loader; // gets the first child of the DisplayObjectContainer, which is a Loader (not sure why)
    var mc:MovieClip = loader.content as MovieClip; //access to the main timeline of the Loader's content (cast as a MovieClip, because we can then call ambiguous functions with no errors. I assume if your loaded swf had a document class you could cast it as the document class here)
    mc.reset(); // call the function inside our loaded SWF
}
于 2011-06-24T17:08:33.833 に答える