2 Replies Latest reply on Jan 10, 2007 1:00 PM by Matthew_Soldo

    Embedding multiple images referenced in XML file

      Hi Flex Community,
      I'm having trouble with this one. I have an xml file that looks like this (although it could be much longer):
      <frame id="1">
      <name>Wedding Frame</name>
      <frame id="2">
      <name>Metro Honey</name>
      <frame id="3">
      <name>Woodberry Black</name>

      I had been manually embedding the images as follows:
      public var honeyFrame:Class;

      But know I would like to programatically loop through the xml file and embed each of the images and then reference them in an array (or something similar). The end goal is that I have a single mxImage tag whose source loops through each of the images when a button is pressed. Any help on this would be greatly appreciated.

      Matthew Soldo
        • 1. Re: Embedding multiple images referenced in XML file
          mac_martine Level 1
          Since the XML won't be loaded until runtime, you can't embed the images. You can only embed assets that are known at compile time. You'll want mx:Loader for this.
          • 2. Re: Embedding multiple images referenced in XML file
            Matthew_Soldo Level 1
            Thanks for the help.

            I tried out using mx:Loader and that worked well, however when doing it this way the images can't be scaled with scale-9, since scale-9 only works with embedded images.

            Is there a way to achieve this if the xml is available at compile time? My goal is to have the a large number (50-100) images emedded programatically such that I can easily make them visible or invisible when a button is pressed (a next image button) and the images must be scalable via scale-9.

            The manual way to do this that I can think of would be to manually embed each one in the code, load the bindable id's of each image into an array, and then have a function which changes the source of an mx:Image to the next item in the array. This function can be called when the button is pushed.... Is there an easier way???