7 Replies Latest reply on Jul 29, 2009 10:49 PM by mahehasan

    how to make source path dynamic

    mahehasan Level 1

      hi,
      i'm new in flex.Here is my problem

      <mx:HorizontalList id="horizontalList" height="100" columnCount="6" dataProvider="{arr}">
      <mx:itemRenderer>
      <mx:Component>
      <mx:Image width="100" height="100" source="../../user/mahedi/weeding/album/{data}"/> /mx:Component>
      </mx:itemRenderer>
      </mx:HorizontalList>

      i want to make source path dynamic. i mean i collected userName and albumName from php and i could print in flex.But when i use in source like this this way source="../../user/{userName}/{albumName}/album/{data}" i fond error. how can i solve that please help me

        • 1. Re: how to make source path dynamic
          Madhav Subedi Level 4

          you need to fetch your dataprovider so that it not only contains the image source but the username and album name too....

           

          <images>

               <image>

                    <userName>user1</userName>

                    <albumName>album1</albumName>

                    <imageName>img1.jpg</imageName>

               </image>

               <image>

                    <userName>user2</userName>

                    <albumName>album2</albumName>

                    <imageName>img2.jpg</imageName>

               </image>

               <image>

                    <userName>user3</userName>

                    <albumName>album4</albumName>

                    <imageName>img4.jpg</imageName>

               </image>

          </images>

          .

          .

          <mx:HorizontalList id="horizontalList" height="100" columnCount="6" dataProvider="{arr}">
          <mx:itemRenderer>
          <mx:Component>
          <mx:Image width="100" height="100" source="../../user/{data.userName}/{data.albumName}/album/{data.imageName}"/>

          </mx:Component>
          </mx:itemRenderer>
          </mx:HorizontalList>

          • 2. Re: how to make source path dynamic
            mahehasan Level 1

            Hi,

            Madhav Subed.Thank you very much for your reply.

            Actually userName and albumNam came from differen file. i mean when i load flex from php userName and albumName came at that time so when i want to show my pictur just i called the php which is like this:

             

            - <root>
            - <images>
            <image>1.jpg</image> 
            <image>2.jpg</image> 
            <image>3.jpg</image> 
            <image>4.jpg</image> 
            <image>5.jpg</image> 
            </images>
            </root>

            and this data i saw with this
            <mx:HBox id="ShowTemplate"  horizontalCenter="0" y="537" borderStyle="solid"
                                    cornerRadius="10" borderColor="#F88B20" width="700" 
                                    borderThickness="2" height="124" verticalAlign="middle" horizontalAlign="center">
                            <mx:HorizontalList id="horizontalList" height="100" columnCount="6" dataProvider="{arr}">               
                                <mx:itemRenderer>
                                    <mx:Component>
                                        <mx:Image id="kk" width="100" height="100" source="'../../user/Mahedi/weeding/album/{data}"/>
                                    </mx:Component>
                                </mx:itemRenderer>
                            </mx:HorizontalList>
            </mx:HBox>
            by called http service. When i use this source="../../user/Mahedi/weeding/album/{data}" there is no problem occur.
            but when i use this source="../../user/{userName}/{albumName}/album/{data}" the builder give me this type of message access of undifined property userName and same for other. I'm also used this
            source="{'../../user/' + username + '/' + albumName + '/album/' + data}"
            Have any solution.
            • 3. Re: how to make source path dynamic
              Madhav Subedi Level 4

              does it mean userName and albumName are the variables you already fetched in your application?

               

              if so, you need to access it through outerDocument, as they are not the part ( member ) of your itemRenderer component.

               

              source="../../user/{outerDocument.userName}/{outerDocument.albumName}/album/{data}"

              • 4. Re: how to make source path dynamic
                mahehasan Level 1

                Thank you very much.

                Yes you are right.

                 

                When i use this path

                source="../../user/{outerDocument.userName}/{outerDocument.albumName}/album/{data}"

                 

                The builder give me like the attach doc(please see attach) file where i set the image

                 

                please reply me.

                • 5. Re: how to make source path dynamic
                  mahehasan Level 1

                  Tank you very much.

                  May be file are not attached cause here occur some problem.

                   

                  When i set the path

                  source="../../user/{outerDocument.userName}/{outerDocument.albumName}/album/{data}"

                   

                  The builder give the message like this with yellow marker

                   

                  Multiple markers at this line:
                  -data binding will not be able to detect assignments to userName
                  and other same message for naother variable

                   

                  Please giude me

                  • 6. Re: how to make source path dynamic
                    Madhav Subedi Level 4

                    declare those two variables BINDABLE in main file.

                     

                    [Bindable] private var userName:String;

                    [Bindable] private var albumName:String;

                    .

                    .

                    .

                    .

                    • 7. Re: how to make source path dynamic
                      mahehasan Level 1

                      Madhav Subedi its great.Thank you very much.