4 Replies Latest reply on Feb 26, 2009 12:09 AM by NaikonBG

    Using property from string

    NaikonBG
      Hi i have a problem with one value

      there is a image with id sgbA1

      with this function:

      private function():void
      {
      Image (sgbA1).source = "white.png";
      }
      it changes but i want the boldt part to be taken from xml
      i have tried Image(myData.getitemat(0).pre).source = "white.png"
      the data stored in myData.getitemat(0).pre is the id of the img i want to use
      but it doesn't work
      i have tried using string but without result again
      so my question is how to set the value in the brackets using data from xml

      I'm sorry if my question is not very clear

      Thnx for the help
        • 1. Re: Using property from string
          Gregory Lafrance Level 6
          What is the result, an error, a broken image icon?
          • 2. Re: Using property from string
            NaikonBG Level 1
            nothing happens no error no broken icon nothing
            Image(sgbA1) - work
            Image("sgbA1") not working
            Image(myData,getItemAt()) - not working
            • 3. Re: Using property from string
              Gregory Lafrance Level 6
              This works. Is the Image actually added to the display list?
              • 4. Re: Using property from string
                NaikonBG Level 1
                I'm sorry it seems that the first time i wasn't able to explain my problem properly i will try again

                1. I have one xml data base it looks something like that

                <Prob1>
                <white>
                <Pre>sgbA1</Pre>
                </white>
                <white>
                <Pre>sgbA2</Pre>
                </white>
                </Prob1>

                I have connected the DB and i try it by setting label.text = myData.getItemAt(0).Pre and it worked fine

                2. I have few Images added to the project with id sgbA1 and sgbA2. They have a default source "blank.png"

                in the script part i have a function

                private function Load():void
                {
                Image().source = "white.png"
                }

                now if in the brakets i wrote sgbA1 its working
                image(sgbA1).source = "white.png" //working

                here comes the problem

                <Pre> sgbA1</Pre>
                --------------- |
                -------------.- V
                Image( ----------------).source = "white.png"

                i want the empty space from the brackets to be filled with the data from the xml table
                i have tried the direct way
                Image(myData.getItemAt(0).Pre).source = "white.png"; //not working
                i have tried declaring a string variable and then use it
                public var str:string;
                str = myData.getItemAt(0).Pre;
                Image(str).source = "white.png" // not working again
                for the test i tried directly use string
                image("sgbA1").source = "white.png" // not working again

                so my question is how to set the empty field in the brackets getting it from the xml table