あなたが尋ねることを行うには2つの方法があります。1 つ目はあなたが求めているように聞こえるもので、2 つ目は私が推奨するものです。
初め:
main.mxml アプリケーションを作成してから、状態ごとに別個の component1.mxml および component2.mxml ファイルを作成します。次に、アプリケーションで次のように設定します。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
<s:states>
<s:State name="State1"/>
<s:State name="State2"/>
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<local:Component1 includeIn="State1"/>
<local:Component2 includeIn="State2"/>
</s:Application>
2 番目の方法、およびアプリケーションの説明のために私が推奨する方法は、アプリケーションを 1 つの swf アプリケーションで複数の swf モジュールに分割します。このようにして、ユーザーは使用する予定のものだけをダウンロードします。このシナリオでは、前と同じことを行いますが、コンポーネントの代わりにモジュールを作成します。
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:local="*">
<s:states>
<s:State name="State1"/>
<s:State name="State2"/>
</s:states>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<mx:ModuleLoader url="Component1.swf" includeIn="State1"/>
<mx:ModuleLoader url="Component2.swf" includeIn="State2"/>
</s:Application>