3 Replies Latest reply on Oct 30, 2009 1:10 PM by Flex harUI

    ItemRenderer events inconsistencies

    danbucholtz1

      I'm noticing some weird things going on in the code I recently wrote.  I wrote a custom ItemRenderer, to render the data in an <mx:List> object.

       

      It works fine for awhile, but after awhile I find that I lose the events for "button mode".  I find that this happens by navigating around the app, so destructing and reconstructing the component.

       

      I'm leaving out the AS which is used to set a variety of text fields at run time.  Nothing too fancy.  If necessary I can post the entire file, but this just doesn't make any sense to me from a coding standpoint.  Since the declarations for the events are in the mxml root, they should be enabled every time the component is created (which is the case, 90% of the time).  Nothing else really interacts with this as it is a stand-alone component, so I don't think anything else could be modifying any properties, etc.

       

      So, to summarize, I have this display class which consists of two sub-components.  One sub component should act as a button (AlertListData.mxml) and thus be in buttonMode and show the hand cursor, as well as have a click handler.  The other sub component has a few LinkButtons, which by default show the hand cursor and highlight a backdrop when moused over.  Sometimes when this component is constructed, it has these properties, other times it does not and I'm not sure why.

       

      Here is the markup for the list.

       

      <mx:List id="list"
           height="100%" width="100%"
           dataProvider="{ Model.Collection }"
           itemRenderer="AlertListRenderer"
           variableRowHeight="true"
           backgroundColor="white"
           verticalScrollPolicy="auto"
           horizontalScrollPolicy="auto"
           itemsChangeEffect="{defaultListEffect}"
      />

       

      Here is the mark-up for the renderer class:

       

      <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:comps="listrenderer.*"
          >
         
          <comps:AlertListData id="dataFields" x="0" y="0" width="100%" height="100%"/>
          <comps:otherClass id="ackAndClear" x="0" y="143" width="100%" height="100%"/>

       

      </mx:Canvas>

       

       

      AlertListData.mxml has the following declaration.

       

      <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
          xmlns:components="common.*"
          styleName="supportImageInit" buttonMode="true"
          useHandCursor="true"
          click="goToFloorPlan()"
          mouseChildren="false"
          >

      </mx:VBox>

       

       

      otherClass.mxml has the following declaration.

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" styleName="supportImageInit">

       

          <mx:Metadata>
              [ResourceBundle("Pinpoint")]
          </mx:Metadata>
         
         
          <mx:Spacer width="5"/>
          <mx:VBox>
              <mx:Image id="grainImg" source="assets/largeGrain.png" />
          </mx:VBox>
          <mx:VBox>
              <mx:Spacer height="10"/>
              <mx:LinkButton enabled="true" label="ACK" icon="@Embed('/assets/ack.png')" click="ack()"
                  id="ack_Btn" cornerRadius="8" rollOverColor="#EB988D"/>
          </mx:VBox>
          <mx:VBox>
              <mx:Spacer height="10"/>
              <mx:LinkButton enabled="false" label="Clear" icon="@Embed('/assets/clear.png')" click="clear()"
                  cornerRadius="8" rollOverColor="#EB988D" id="clear_Btn" buttonMode="true" useHandCursor="true"/>
          </mx:VBox>

      </mx:HBox>