6 Replies Latest reply on Jun 1, 2011 1:36 PM by Maxime Chupin

    SWFLoader and variable loading

    Maxime Chupin

      Hi,

       

      I am descovering Flex and I don't find how to load SWF which depends on the user choice. Let us see my little code to understand what I mean:

       


      <?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"
                     >
      <fx:Script>
              <![CDATA[
                  [Bindable]
                  public var selectedListItem:Object;
             ]]>
          </fx:Script>

       

          <fx:Declarations>
              <fx:Model id="anim">
                  <states>
                      <state label="Pendules" data="pendules"/>
                      <state label="Anguinéa" data="ang-visio"/>
                  </states>
              </fx:Model>
          </fx:Declarations>

       

          <s:Panel title="Halo List Control Example"
                  width="300"  x="500" y="50">
              <s:VGroup left="10" right="10" top="10" bottom="10">
                  <s:Label text="Selectionner une animation"/>
              <s:Label text="Actuellement '{selectedListItem.data}'.swf"/>
                  <mx:List id="source" width="100%" color="blue"
                          dataProvider="{anim.state}"
                          change="selectedListItem = List(event.currentTarget).selectedItem"/>
              </s:VGroup>
          </s:Panel>
        <s:Panel x="30" y="50">
          <mx:SWFLoader autoLoad="true" source="@Embed('{selectedListItem.data}.swf')"/>
        </s:Panel>
      </s:Application>

       

      Moreover, I think it is weird to embed a "variable" swf, but I do not manage to load a SWF without @Embed. Why?

       

      Thanks for help !