2 Replies Latest reply on May 2, 2009 12:04 PM by tfcenturion

    how to do itemrendering in actionscript

    tfcenturion

      Hi all,

       

      I trying to convert this item renderer on the image tag to as3 in a script block.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" horizontalCenter="middle" verticalCenter="middle" width="60" height="60" >
          <mx:Image x="5" y="2" width="50" height="50" source="{data.image}" toolTip="{data.toolTip}" />
      </mx:Canvas>

       

      I know this might sound redundant as this does work but i need this to work in a horizontalList and give it a option to dull out an item should i not wont the user to click on it but to see it.

       

      The reason behind this approach is then to allow the user to see for example a list of clothes but only allowed to select those in his price range, therefore greying out the one he cant afford.

       

      I have tryed this below but...

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" horizontalCenter="middle" verticalCenter="middle" width="60" height="60" >

          <mx:Script >
              <![CDATA[
              import mx.controls.Image;
             
              private var _image:Image;
             
              _image = new Image;
             
              _image.source = data.image;
             
              ]]>
          </mx:Script>

      </mx:Canvas>

       

      all i get is variable data is not defined.

       

       

       

      all help gratefull..

       

      Paul

        • 1. Re: how to do itemrendering in actionscript
          Michael Borbor Level 4

          Wrap the new Image() and _image.source inside a function and trigger 

          that function with the creation complete event.

           

          Sincerely,

           

          Michael

           

          El 02/05/2009, a las 9:35, tfcenturion <forums@adobe.com> escribió:

           

          >

          Hi all,

          >

          I trying to convert this item renderer on the image tag to as3 in a 

          script block.

          >

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml

          horizontalCenter="middle" verticalCenter="middle" width="60" 

          height="60" >

              <mx:Image x="5" y="2" width="50" height="50" 

          source="{data.image}" toolTip="{data.toolTip}" />

          </mx:Canvas>

          >

          I know this might sound redundant as this does work but i need this 

          to work in a horizontalList and give it a option to dull out an item 

          should i not wont the user to click on it but to see it.

          >

          The reason behind this approach is then to allow the user to see for 

          example a list of clothes but only allowed to select those in his 

          price range, therefore greying out the one he cant afford.

          >

          I have tryed this below but...

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml

          horizontalCenter="middle" verticalCenter="middle" width="60" 

          height="60" >

              <mx:Script >

                  <![CDATA[

                  import mx.controls.Image;

          >

                  private var _image:Image;

          >

                  _image = new Image;

          >

                  _image.source = data.image;

          >

                  ]]>

              </mx:Script>

          </mx:Canvas>

          >

          all i get is variable data is not defined.

          >

          >

          >

          all help gratefull..

          >

          Paul

          >

          • 2. Re: how to do itemrendering in actionscript
            tfcenturion Level 1

            Cheers Michael,

             

            spot on, that sorted...

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" horizontalCenter="middle" verticalCenter="middle" width="60" height="60" creationComplete="{drawImage(data.image, data.toolTip)}" >
                <mx:Script >
                    <![CDATA[
                    import mx.controls.Image;
                   
                    private var _image:Image;
                   
                    private function drawImage(iS:String, tT:String):void
                    {
                        // Create New Image. //
                        _image = new Image;
                       
                        // Set Image X&Y Loc and Width and Height. //
                        _image.x = 5;
                        _image.y = 2;
                        _image.width = 50;
                        _image.height = 50;
                       
                        // Set Image Path and Tool Tip. //
                        _image.source = iS;
                        _image.toolTip = tT;
                       
                        // Place Image on the Stage. //
                        addChild(_image);

                    }
                   
                    ]]>
                </mx:Script>
            </mx:Canvas>

             

            I know this is more code than what is was before but i need to do checking on this too, hence the need to have it this way.

             

             

            Again cheers....

             

            Paul