1 Reply Latest reply on Jul 17, 2007 5:20 PM by ntsiii

    Actionscript in a Custom Component

    joe28sfl Level 1
      Can anyone tell me if you can put actionscript inside of a custom component? It throws errors anytime I try to do it.

      I have a horizontallist component that is being populated with an itemrenderer which holds an image component. The horizontallist takes fifteen images and loads them into the itemrenderers, creating a scrollable image slideshow.

      Here is the code for the horizontallist:
      <mx:HorizontalList
      id="imageBar"
      itemRenderer="listingImage"
      height="330"
      width="925"
      paddingLeft="5"
      paddingRight="5"
      rollOverColor="#FFFFFF"
      selectionColor="#FFFFFF"
      >

      And the code for the custom component.....
      <mx:Canvas
      xmlns:mx=" http://www.adobe.com/2006/mxml"
      height="320"
      width="400"
      verticalScrollPolicy="off"
      horizontalScrollPolicy="off"
      >
      <mx:Image
      source=" http://www.realestate-websites.com/idx/rmls/images/resimages/{data.id}_{data.imageNum}.jpg "
      height="300" scaleContent="true"
      />

      </mx:Canvas>
        • 1. Re: Actionscript in a Custom Component
          ntsiii Level 3
          First, the answer to yur question is yes, you can definitely put AS code in custom components.

          You are mixing in-line renderer syntax with component-based syntax. You component renderer does not know anything about "data". You need to override the set data() function, which will give you access to the dataProvider item.

          You need to look at an example of a custom ItemRenderer. There are many, I have several on cflex.net.

          Tracy