2 Replies Latest reply on Aug 11, 2006 11:56 AM by looklisten

    Events and Nested Components

    looklisten
      This issue has been driving me absolutely crazy. I've reduced the problematic code down to a bare-bones example that demonstrates the problem I'm having.

      Why is it that this generates a "1009: Null object" error:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[

      public function trackProgress():void{

      var steps_completed:int=0;

      (rb_high_def_y.selected || rb_high_def_n.selected) ? steps_completed+=1 : null;
      (rb_dvr_y.selected || rb_dvr_n.selected) ? steps_completed+=1 : null;


      }
      ]]>
      </mx:Script>

      <mx:Accordion id="a_accordion">
      <mx:VBox id="v_test">
      <mx:RadioButton id="rb_high_def_y" groupName="r_high_def" label="Yes" click="trackProgress()" />
      <mx:RadioButton id="rb_high_def_n" groupName="r_high_def" label="No" click="trackProgress()" />
      </mx:VBox>
      <mx:VBox id="v_test2" y="50">
      <mx:RadioButton id="rb_dvr_y" groupName="r_dvr" label="Yes" click="trackProgress()" />
      <mx:RadioButton id="rb_dvr_n" groupName="r_dvr" label="No" click="trackProgress()" />
      </mx:VBox>
      </mx:Accordion>
      </mx:Application>

      While when the accordion is taken out, it does not:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">
      <mx:Script>
      <![CDATA[

      public function trackProgress():void{

      var steps_completed:int=0;

      (rb_high_def_y.selected || rb_high_def_n.selected) ? steps_completed+=1 : null;
      (rb_dvr_y.selected || rb_dvr_n.selected) ? steps_completed+=1 : null;


      }
      ]]>
      </mx:Script>

      <mx:VBox id="v_test">
      <mx:RadioButton id="rb_high_def_y" groupName="r_high_def" label="Yes" click="trackProgress()" />
      <mx:RadioButton id="rb_high_def_n" groupName="r_high_def" label="No" click="trackProgress()" />
      </mx:VBox>
      <mx:VBox id="v_test2" y="50">
      <mx:RadioButton id="rb_dvr_y" groupName="r_dvr" label="Yes" click="trackProgress()" />
      <mx:RadioButton id="rb_dvr_n" groupName="r_dvr" label="No" click="trackProgress()" />
      </mx:VBox>
      </mx:Application>

      I simply don't understand what's going on here. If anyone else can I will be most appreciative!