2 Replies Latest reply on Jan 28, 2008 12:45 PM by ChiefRocka00

    Change TileList background color

    ChiefRocka00 Level 1
      So I am getting the TileList to refresh every second via the setInterval calling my HTTPService. I am populating the TileList with a custom itemRenderer and there is conditional logic to change the background color of the tile. However, when my data is updated via setInterval the background color does not change along with it. How can I have the function called to set the background color when the value of the data changes for each tile? Here is my item renderer:

      <?xml version="1.0"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init();">
      <mx:Style>
      .mySquare { backgroundColor: yellow; }
      .availSquare { backgroundColor: white; }
      .takenSquare { backgroundColor: gray; }
      </mx:Style>
      <mx:Script>
      <![CDATA[

      import flash.events.Event;
      import mx.controls.Alert;
      import mx.collections.*;
      import mx.core.IFlexDisplayObject;
      import mx.managers.PopUpManager;

      override public function set data(value:Object):void {
      if ( value != null ) {
      super.data = value;
      }
      }

      public function init():void {
      if ( data.Taken != "Y" ) {
      theBox.styleName = "availSquare";
      } else if ( lblOwnerName.text == parentApplication.personData.displayName.toString() ) {
      theBox.styleName = "mySquare";
      } else {
      theBox.styleName = "takenSquare";
      }
      }

      public function cellClick(event:Event):void {
      var ownerText:String = lblOwnerName.text;
      if ( ownerText.substr(0,3) == "BUY" ) {
      confirmSquareSelection(data.Cell);
      }
      }

      private function confirmSquareSelection(squareId:int):void {
      var confirmPopUp:IFlexDisplayObject = PopUpManager.createPopUp (this, ConfirmWindow, true);
      ConfirmWindow( confirmPopUp ).squareId = squareId;
      ConfirmWindow( confirmPopUp ).leagueId = parentApplication.personData.leagueId.toString();
      PopUpManager.centerPopUp( confirmPopUp );
      }
      ]]>
      </mx:Script>

      <mx:VBox width="100%"
      id="theBox"
      height="100%"
      horizontalAlign="center"
      borderColor="#000000"
      borderStyle="solid"
      borderThickness="1"
      styleName="availSquare"
      verticalGap="0"
      cacheAsBitmap="true">

      <mx:Spacer height="8"/>
      <mx:Label id="lblOwnerName"
      text="{data.Owner}"
      click="cellClick(event)"
      textAlign="center"
      width="100%"
      height="100%"
      verticalCenter="0"/>
      </mx:VBox>

      </mx:Canvas>