3 Replies Latest reply on Mar 14, 2008 7:13 PM by ntsiii

    ItemRenderer communication between main App and ItemRenderer

    Tikis_Mikis Level 1
      Hello if anyone has been paying attention to my nagging comments, I am stuck in getting a List/Itemrenderer working. I need to find a way go get the data from each checkbox thats selected (I have a list with an Hbox, checkbox/label combination) have been clicked by user. Here is a sample code and I think it's enough to show what I am trying to do:

      // sample list component in my main app, Main.as:
      var newList1:List = new List();
      newList1.id = "newList1";
      newList1.dataProvider = phpData;
      newList1.allowMultipleSelection = true;
      newList1.width = 200;
      newList1.height = 400;
      newList1.x = 10;
      newList1.y = 20;
      newList1.itemRenderer = new ClassFactory(CheckBoxRenderer);
      newList1.setStyle("alternatingItemColors", new Array("#EEEEEE", "white"));
      myCanvas.addChild(newList1);

      ########################################################
      here is my AS3 itemrenderer, CheckBoxRenderer.as:
      // CheckBoxRenderer.as
      package FormComponents {
      import mx.controls.CheckBox;
      import flash.events.Event;

      public class CheckBoxRenderer extends CheckBox
      {
      public function CheckBoxRenderer()
      {
      super();
      // => Add listener to detect change in selected
      this.addEventListener(Event.CHANGE, onChangeHandler);
      }

      // Override the set method for the data property.
      override public function set data(value:Object):void
      {
      super.data = value;
      // => Make sure there is data
      if (value != null) {
      // => Set the label
      this.label = value.label;
      // => Set the selected property
      this.selected = value.isSelected;
      }

      // => Invalidate display list,
      // => If checkbox is now selected, we need to redraw
      super.invalidateDisplayList();
      }

      // => Handle selection change
      private function onChangeHandler(event:Event):void
      {
      super.data.isSelected = !super.data.isSelected;
      }
      }
      }

      (thanks to Kaotic101 for showing me how to do the AS3 ItemRenderer)

      So I need to store the values in a DB that have been checked by a user.

      HOW DO I ACCESS THE ITEMRENDER VALUES FROM MY MAIN.AS FILE??

      I found this by Peter Ent http://weblogs.macromedia.com/pent/ and he says that he will have an upcoming article on itemrendere communication with the main app. Does anyone know when it will come out?

      Thanks!