2 Replies Latest reply on Sep 8, 2008 5:53 AM by Epharian

    How to use an Embedded Image in an arrray?

    Epharian
      ACK!

      Okay, I'm a moderately experience php coder, but pretty new to flex and actionscript in general.

      I have an application where I need to load a series of images and embed them into the application (not at runtime), then have them accessible in an array so that I can work through them later on in a reasonable fashion (I'm displaying them to the user of the application multiple times, and perhaps randomly--having them in the array is the BEST way to do this, but I need it to be embedded since there won't need to be that many images).

      What I'm having trouble with is this:

      My code simply doesn't seem to work the way I think it should. The listed code doesn't actually seem to load the images INTO the array. What am I doing wrong?

      Thanks for the help, and please let me know.




        • 2. Re: How to use an Embedded Image in an arrray?
          Epharian Level 1
          quote:

          Originally posted by: Greg Lafrance
          This seems to work:



          That's helpful--so I know that I'm approximating the right method for setting up the array. The only question then remains--what's going wrong with the rest of the code? Because this provides a blank page except for the labels (Thanks in advance):

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute"
          backgroundColor="#FFFFFF">
          <mx:Script>
          <![CDATA[
          [Embed(source="avatar2.jpg")]
          [Bindable]
          public var img:Class;
          [Embed(source="pic.gif")]
          [Bindable]
          public var img2:Class;
          public var pics:Array = new Array(img, img2);

          ]]>
          </mx:Script>
          <mx:Grid x="10" y="10" width="100%" height="383">
          <mx:GridRow width="100%" height="100%">
          <mx:GridItem width="100%" height="100%">
          <mx:Label
          text="Bad"
          width="103"
          height="32"
          id="TopLeft"
          enabled="true"
          fontWeight="bold"
          color="#0B333C"
          fontSize="20"/>
          </mx:GridItem>
          <mx:GridItem width="100%" height="60">
          </mx:GridItem>
          <mx:GridItem width="100%" height="100%">
          <mx:Label
          text="Good"
          width="100%"
          height="32"
          id="TopRight"
          enabled="true"
          fontSize="20"
          color="#0B333C"
          fontWeight="bold"
          textAlign="right"/>
          </mx:GridItem>
          </mx:GridRow>
          <mx:GridRow width="100%" height="32">
          <mx:GridItem width="100%" height="100%">
          <mx:Label
          text=""
          id="BottomLeft"
          enabled="false"
          fontSize="20"
          color="#0B333C"
          fontWeight="bold"/>
          </mx:GridItem>
          <mx:GridItem width="100%" height="100%" label="Hello">
          </mx:GridItem>
          <mx:GridItem width="100%" height="100%">
          <mx:Label
          text=""
          id="BottomRight"
          width="100%"
          enabled="false"
          fontWeight="bold"
          color="#0B333C"
          fontSize="20"
          textAlign="right"/>
          </mx:GridItem>
          </mx:GridRow>
          <mx:GridRow width="100%" height="299">
          <mx:GridItem width="100%" height="100%">
          </mx:GridItem>
          <mx:GridItem width="100%" height="100%">
          <mx:Image
          source="{pic[0]}"
          id="pic"
          width="250"
          autoLoad="true"/>
          </mx:GridItem>
          <mx:GridItem width="100%" height="100%">
          </mx:GridItem>
          </mx:GridRow>
          </mx:Grid>
          </mx:Application>