0 Replies Latest reply on Dec 12, 2011 2:33 AM by rajesh_android

    Problems regarding a cutoms item renderer

    rajesh_android

      Hello,

       

      I have created a custom item renderer whcih contains two labels and a button. this list is populated on a sertain event. but this list behaves very weird when the triggering event is triggered second time and so on.

      What happens is the content set to labels labelFuntion are chaned or changes their place if I set them dynamically. And they do not change even if I want to when they are placed statically. I am attaching my code  herewith

       

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

      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

                      xmlns:s="library://ns.adobe.com/flex/spark"

                      left="5"  autoDrawBackground="false"  creationComplete="_initializeHandler(event)"

                      fontSize="12" fontWeight="bold" resize="itemrenderer1_resizeHandler()"

                      width="100%"  cachePolicy="on">

         

          <fx:Script>

              <![CDATA[

                  import mx.collections.ArrayCollection;

                  import mx.events.FlexEvent;

                  import mx.events.ResizeEvent;

                  import mx.managers.PopUpManager;

                 

                  import skins._alert;

                  import skins.creoCustomButtons;

                  import skins.logoutConf;

                 

                  import spark.components.CheckBox;

                  import spark.events.PopUpEvent;

                  private var but:Button;

                  private var a:_alert;

                  public var timer2:Timer;

                  import spark.components.Button;

                  private var cb:CheckBox;

                  private var confirmation:logoutConf;

                  private var tempo:String;

                  public static var _temp_array:Array = new Array();

                  import skins.radioButtonList;

                  public var _billingCycle:radioButtonList;

                  public var subOptions:ArrayCollection;

                  [Bindable]public var initiator:int = 0;

                  public static var config_data_Temp:ArrayCollection = new ArrayCollection();

                  public static var counter:int = new int();

                 

                 

                  public function confirmAction(event:MouseEvent):void{

                     

                      //    config_data_Temp.removeItemAt(data.subOptions[this.data].name);

                     

                      subOptions = new ArrayCollection(data.subOptions);

                      _billingCycle = new radioButtonList;

                      _billingCycle.dataProvider = subOptions;

                      _billingCycle.labelField = "name";

                      _billingCycle.width = stage.width;

                      _billingCycle.height = stage.height ;

                      _billingCycle.addEventListener(PopUpEvent.CLOSE, selectedValue);

                      _billingCycle.open(this,true);

                     

                  }

                 

                  public function selectedValue(event:PopUpEvent):void{

                     

                      if(event.commit){

                         

                          var selectedItems:Vector.<Object> = event.data as Vector.<Object>

                         

                          for(var i:int = 0; i<GlobalData.configurations_data.length; i++){

                             

                              var tempo:String = GlobalData.configurations_data.getItemAt(i,0).toString();

                              //if(config_data_Temp[i]==this.name)

                              if(tempo==btn.label.toString())

                              {

                                  GlobalData.configurations_data.removeItemAt(i);

                                  GlobalData.configurations_data.addItemAt(selectedItems[0].name, i);

                                 

                                  _price.text = GlobalData.configurations_data[i].price;   

                              }

                             

                          }

                          type.text = selectedItems[0].name;

                         

                          btn.label = selectedItems[0].name;

                         

                          //GlobalData.configurations_data = null;

                          //GlobalData.configurations_data = config_data_Temp;

                         

                      }

                     

                  }

                 

                  private function processRequest(event:PopUpEvent):void{

                     

                      if(event.commit)

                      {

                          _temp_array.push(data.domain_name+data.tldname);

                          GlobalData.domain_name_data = _temp_array;

                         

                          a = new _alert();

                          a.title = "Request Status";

                          a.message = "Your request is successfully processed.\n Check you email account for details";

                          a.open(this.parent, true);

                          PopUpManager.centerPopUp(a);

                          timer2 = new Timer(2000, 1);

                          timer2.addEventListener(TimerEvent.TIMER_COMPLETE,timerComplete2);

                          timer2.start();

                      }

                     

                  }

                 

                  /*       

                  Timer coplete event closing the current displayed popup

                 

                  text="{data.subOptions[0].optFees}"

                 

                  label="{data.subOptions[0].name}"

                  */   

                 

                  public function  timerComplete2(event:TimerEvent):void

                  {

                      a.close()

                  }

                 

                 

                  public function itemrenderer1_resizeHandler():void{

                     

                      if(but){

                          but.x = (this.parent.width-but.width)-10;

                         

                      }

                      if(confirmation)

                      {

                          PopUpManager.centerPopUp(confirmation);

                      }

                      if(a)

                      {

                          PopUpManager.centerPopUp(a);

                      }

                  }

                 

                  public var myButon:Button;

                 

                  protected function _initializeHandler(event:FlexEvent):void

                  {

                     

                      btn.label = data.subOption[0].name;

                     

                  }

                 

                 

              ]]>

          </fx:Script>

         

          <s:HGroup height="30" width="100%" verticalAlign="middle" gap="0">

             

             

              <s:Label width="30%" text="{data.name}"

                       fontSize="10" fontWeight="normal" id="type"/>

              <s:Label  id ="_price" width="10%"

                       fontSize="10" fontWeight="normal"/>

             

              <s:Button  fontSize="12" fontWeight="normal"

                        skinClass="skins.creoCustomButtons" chromeColor="#ffffff"

                        click="confirmAction(event)" width="60%"  id="btn"/>

             

         

          </s:HGroup>

         

      </s:ItemRenderer>

       

       

      NOTE: [ Please ignore comments and import statements ]

       

      The button pops up a radio button list. After an item is clicked the selected text should be placed on button permenantly, which is not happening in current scenario.

       

       

      Any kind of help is appreciated!