2 Replies Latest reply on Mar 5, 2009 7:07 AM by AnneGFilms

    SwfLoader & Embed directive within Repeater

    AnneGFilms Level 1
      I experimenting with how to build/use XML data in Flex. This isn't a true design, but I'm curious why it fails.
      I would like to dynamically load asset file names from XML and embed them in a SWFLoader tag. The Embed directive fails to use/find the file.

      All the lines below render as expected at runtime except for line 2. Lines 1&2 use the exact same binding from the repeater, but only line 1 renders properly:

      Line 1 verifies that the file name is properly extracted from the repeater value binding (i.e. assets/PreplinkLaunch.swf')
      Line 3&4 verify that the SWFLoader renders the asset if the file name is hard-coded.

      XML:
      <examples>
      <swf id="1" src="assets/PreplinkLaunch.swf" />
      </examples>
      MXML:
      <mx:Repeater id="swfFile" dataProvider="{examples.swf}" count="{examples.swf.length()}">
      1. <mx:TextInput id="fileName" text="{swfFile.currentItem.@src}"/>
      2. <mx:SWFLoader width="300" height="300" source="@Embed(source='{swfFile.currentItem.@src}')" />
      3. <mx:SWFLoader width="300" height="300" source="@Embed(source='assets/PreplinkLaunch.swf')" />
      4. <mx:SWFLoader width="100" height="100" source="assets/PreplinkLaunch.swf" />
      </mx:Repeater>
        • 1. Re: SwfLoader &amp; Embed directive within Repeater
          Level 7

          "pghpang" <webforumsuser@macromedia.com> wrote in message
          news:gomari$i2r$1@forums.macromedia.com...
          >I experimenting with how to build/use XML data in Flex. This isn't a true
          > design, but I'm curious why it fails.
          > I would like to dynamically load asset file names from XML and embed them
          > in a
          > SWFLoader tag. The Embed directive fails to use/find the file.
          >
          > All the lines below render as expected at runtime except for line 2.
          > Lines
          > 1&2 use the exact same binding from the repeater, but only line 1 renders
          > properly:
          >
          > Line 1 verifies that the file name is properly extracted from the repeater
          > value binding (i.e. assets/PreplinkLaunch.swf')
          > Line 3&4 verify that the SWFLoader renders the asset if the file name is
          > hard-coded.
          >
          > XML:
          > <examples>
          > <swf id="1" src="assets/PreplinkLaunch.swf" />
          > </examples>
          > MXML:
          > <mx:Repeater id="swfFile" dataProvider="{examples.swf}"
          > count="{examples.swf.length()}">
          > 1. <mx:TextInput id="fileName" text="{swfFile.currentItem.@src}"/>
          > 2. <mx:SWFLoader width="300" height="300"
          > source="@Embed(source='{swfFile.currentItem.@src}')" />
          > 3. <mx:SWFLoader width="300" height="300"
          > source="@Embed(source='assets/PreplinkLaunch.swf')" />
          > 4. <mx:SWFLoader width="100" height="100"
          > source="assets/PreplinkLaunch.swf" />
          > </mx:Repeater>
          >

          Embedding happens at compile time. Your code executes at runtime. See the
          issue?