0 Replies Latest reply on Jun 30, 2011 12:44 AM by Magick9393

    error when adding headerrenderer in actionscript

    Magick9393 Level 1

      Hi

       

      I have a custom headerrender for an accordion, and when I add it using mxml it works fine. But when I try to add it using actionscript I get a null pointer exception.

       

      this is the headerrenderer:

      <CanvasButtonAccordionHeader

       

       

      verticalScrollPolicy="off" horizontalScrollPolicy="off"

      xmlns="

      http://code.google.com/p/flexlib/" mouseChildren="true"

      xmlns:mx="

      http://www.adobe.com/2006/mxml">

       

       

      <mx:Script>

      <![CDATA[

       

       

      import mx.containers.Accordion;

       

      import mx.controls.Alert;

       

      [

      Bindable]

       

      private var _label:String;

       

       

      private var _accordion:Accordion;

       

      [

      Bindable]

       

      public var selectedBtn:Boolean=false;

       

       

      override public function set label(value:String):void {

       

      super.label = "";

       

      _label = value;

      }

       

       

      /* private function onButtonClick(event:Event):void{

      //mx.controls.Alert.show("accordion button clicked");

      _accordion = event.currentTarget.parent.parent.parent.parent;

      var header:DisplayObject = _accordion.getHeaderAt(1); //eu.europa.eurostat.HeaderRenderer

      var children:Array=_accordion.getChildren();

      children.forEach(forEach_accordionHeader);

       

       

      }

       

      private function forEach_accordionHeader(element:*, index:int, arr:Array):void {

       

      var header:DisplayObject = _accordion.getHeaderAt(index);

      } */

       

       

       

      ]]>

       

       

      </mx:Script>

       

       

      <mx:VBox width="100%" height="100%" verticalAlign="middle" horizontalAlign="left" paddingLeft="5" paddingRight="5">

       

       

      <!--<mx:CheckBox click="onButtonClick" mouseDown="event.stopImmediatePropagation()" />

      <mx:RadioButton click="onButtonClick(event)" selected="{selectedBtn}" groupName="identifyGroup" /> -->

       

       

      </mx:VBox>

       

       

      <mx:VBox width="100%" height="100%" verticalGap="0" verticalAlign="middle" paddingLeft="20">

       

       

      <!--<mx:ComboBox prompt="{_label}" id="combo" cornerRadius="0" mouseDown="event.stopImmediatePropagation()" click="event.stopImmediatePropagation()">

      <mx:dataProvider>

      <mx:Array>

      <mx:String>Menu Item 1</mx:String>

      <mx:String>Menu Item 2</mx:String>

      <mx:String>Menu Item 3</mx:String>

      <mx:String>Menu Item 4</mx:String>

      </mx:Array>

      </mx:dataProvider>

      </mx:ComboBox>-->

       

       

      <mx:Label text="{_label}">

       

      </mx:Label>

       

       

      </mx:VBox>

       

       

       

      </CanvasButtonAccordionHeader>

       

       

      And this is the code I am using to (try to) add it:

      var

       

       

      subGrpContainer:Accordion = new Accordion();

       

      var subGrpHeader:eu.europa.eurostat.HeaderRenderer = new eu.europa.eurostat.HeaderRenderer();

      subGrpHeader.label =

      "test";

       

      subGrpContainer.headerRenderer=subGrpHeader

      as mx.core.IFactory;

       

      if anyone can tell me what I am doing wrong, I would greatly appreciate the help.