2 Replies Latest reply on Dec 13, 2011 11:03 PM by Chellaa2011

    How to set the source property of image control dynamically?

    Chellaa2011 Level 1

      Hi,

        I have different fxg files which I want to display in a list. For each row in the List, I define which fxg file to be displayed in my database.

       

      I need to know how to set the image1.source = (the fxg path) as a string from database?

       

      Is there any conversion needed in this case? If so, can you please help me how to do this?

        • 1. Re: How to set the source property of image control dynamically?
          nikos101 Level 2

          You should be able to give you fxg path an id and get the source from it like this

           

          fxgObject.pathid.source

           

          failing that you could use regex to extract it

          • 2. Re: How to set the source property of image control dynamically?
            Chellaa2011 Level 1

            Hi,

              Thank you for your response. I am new to Adobe Flash Builder, Flex and action script. I don't get your answer straight away.

             

            What I basically need is, I need to set image1.source = strFXG. Right now, this does not show the image. I don't understand fxgObject.pathid.source => how to give this?

             

            Moreover, when I did google search, there is somethink like fxg converter which converts the fxg to a component. I thought this is a very simple problem on how to convert the fxg string to an object format. But now, it looks like it might be a big problem. Can anyone help me in this?

             

            ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ --------------------------------------------------

             

            import spark.components.Image;

             

                                          protected function view1_creationCompleteHandler(event:FlexEvent):void

                                          {

              // TODO Auto-generated method stub

             

              var strFXG:String = 'assets.DB_Actief_Graphics';

             

                                                    var image1:Image = new Image();

                                                    image1.x = 100;

                                                    image1.y = 100;

                                                    image1.source = strFXG;

                                                    addElement(image1);

                                          }

             

            ------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ --------------------------------------------------

             

            Regards,

            Chella