3 Replies Latest reply on Jun 22, 2010 11:13 PM by BhaskerChari

    access image in item render

    miguel8312 Level 3

      hello guys i have an item renderer

      like so

      <mx:Component>
      
      
      
      <mx:HBox width="100%" height="70" paddingLeft="0" paddingRight="0">
      
      
      
      <mx:Image id="gb"  source="assets/Warning.png" enabled="true" alpha="1" click="outerDocument.ShowPidmHideDuplicate();"  useHandCursor="true" buttonMode="true"/>
      
      
      <mx:Text id="stext" text="{data.fwvitals_messageA}" 
                          fontFamily="
      
      Georgia"                     fontSize="
      
      14" fontWeight="bold" />
      
      
      <mx:Image id="his" source="assets/history.png" enabled="true" alpha="1" useHandCursor="true" buttonMode="true"/>
      
      
      </mx:HBox>
      
      
      </mx:Component>
      
      
      

       


      I would like to access the image in the item renderer so i can change it to something else using actionscript 3.0 does anyone know how does one go about doing this?

        • 1. Re: access image in item render
          BhaskerChari Level 4

          Hi miguel,

           

          You can access the image in your itemRenderer the following way by writing the ActionScript block within the itemRenderer...

           

          <mx:itemRenderer>
              <mx:Component>
               <mx:HBox width="100%" height="70" paddingLeft="0" paddingRight="0">
                <mx:Script>
                            <![CDATA[
                                           
                         private function changeImage():void
                         {
                            gb.source = "assets/Warning1.png";
                            his.source = "assets/history1.png";
                         }
                            ]]>
                        </mx:Script>
                <mx:Image id="gb"  source="assets/Warning.png" enabled="true" alpha="1" click="outerDocument.ShowPidmHideDuplicate();"  useHandCursor="true" buttonMode="true"/>
                <mx:Text id="stext" text="{data.fwvitals_messageA}" fontFamily="Georgia" fontSize="14" fontWeight="bold" />
                <mx:Image id="his" source="assets/history.png" enabled="true" alpha="1" useHandCursor="true" buttonMode="true"/>
               </mx:HBox>
              </mx:Component>
          </mx:itemRenderer>

           

           

          You can call the function changeImage() either on a button click or any event you want to chnage the source of image..

           

          If this post answers your question or helps, please kindly mark it as such.


          Thanks,

          Bhasker Chari

          1 person found this helpful
          • 2. Re: access image in item render
            miguel8312 Level 3

            Thank you

            BhaskerChari

            thought i already knew i can use the the actionscript withing my render it was still helpful. However i took a bit of a different approach hope this helps someone some day. I used a variable like the below and then on my actionscript when i got a respond from my webservice cahnge the string depending on the result... that seemed to work like a charm.

            
            
            Public var imgStringe:String = new String();
            
            <mx:Image id="gb2"  source="{parentDocument.imgStringe}" enabled="true" alpha="1" click="outerDocument.ShowPidmHideDuplicate();"  useHandCursor="true" buttonMode="true"/>
            

            Thanks

            Miguel

            • 3. Re: access image in item render
              BhaskerChari Level 4

              Hi Miguel,

               

              Yes you can access using the parentDocument propert to access the variables or public properties in the parent doument.

               

              But your question was not clear...whether you want to access the image in the parentDocument in your itemRenderer..

               

              So I thought you want to modify from with in the itemRenderer..

               

              Thanks,

              Bhasker Chari