4 Replies Latest reply on Feb 7, 2011 11:00 AM by Pablo Souza

    Hi.  complete newbie here.

    olddummy Level 1

      trying to use a value stored in a variable as a link to an image.


      image soure = "../asset/mypic.jpg"  works but


      var mypic:String = "../asset/mypic.jpg"

      image source = mypic


      image source = "mypic"


      doesn't, should it?

        • 1. Re: Hi.  complete newbie here.
          Pablo Souza

          There are a lot of ways to do that:


          You can specify the image source:

          <mx:Image source="mypic.jpg"/> 
          <mx:Image source="@Embed(source='mypic.jpg')"/> 
          <mx:Image source="@Embed(source='assets/mypic.jpg')"/> 
          <mx:Image id="image1"/> 


          Or you can set the image source at runtime:

          // Retrieve the image
          private function getImage():void 
              var imageSource:String = "../asset/mypic.jpg"


          Or also you can embed the image:

          public var imgClass:Class;
          <mx:Image source="{imgClass}"/>




          Best regards,

          Pablo Souza

          • 2. Re: Hi.  complete newbie here.

            Pablo hi. thanks for your response.


            past.load(ResourceManager.number1); this loads an mx image with a picture which is defined in the ResourceManager.as file it works



            past.load(cardaddress); doesn't but cardaddress holds ResourceManager.number1 (i put a trace on it and it definitely holds this value)


            past.source =

            "../assets/Ace of hearts";  this works reading the picture direct from the folder that it is in.


            past.source ="(cardaddress)"

            past.source ="{cardaddress}"

            past.source ="cardaddress" doesn't


            so whenever i hold the address value in a variable it all fails, surely i should be able to.


            Sorry i am sure i am being obtuse but i have a lot of pictures and wish to address them by building a variable string.



            • 3. Re: Hi.  complete newbie here.
              baldoldkp Level 1

              my apologies again.

              image.load(variable) works.!!

              many many thanks

              • 4. Re: Hi.  complete newbie here.
                Pablo Souza Level 3

                Nice it works!



                Best regards,

                Pablo Souza