0 Replies Latest reply on Dec 13, 2011 12:25 AM by prithvi.zankat

    Dispatching GridSelectionEvent throw exception at runtime - A build issue with FB 4.5

    prithvi.zankat

      This is a strang probelm I am facing with.

      My code dispatches GridSelectionEvent after setting girds' selected item in one logic path. Following is code lines -

       

      myDataGrid.selectedItem = instanceTag;

      myDataGrid.dispatchEvent(new GridSelectionEvent(GridSelectionEvent.SELECTION_CHANGE));

       

      Flash player throws following error on above statements encounter -


      TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at spark.accessibility::DataGridAccImpl/eventHandler()

          at flash.events::EventDispatcher/dispatchEventFunction()

          at flash.events::EventDispatcher/dispatchEvent()

          at mx.core::UIComponent/dispatchEvent()

       

      I am saying it is a strang for me because when I use swf file generated by Flex Builder (4.5)'s export to release build, it does not throw error and code works fine as expected.

      But, when I user swf file generated by Ant script, I face the above issue.

       

      The Flex builder settings is as shown in following image -

       

      FB Settings.png

      Ant  mxmlc script is as follow -

       

      <mxmlc      

                 file="${basedir}/src/AppMonConfigWizard.mxml"

                  static-rsls="false"

                 keep-generated-actionscript="false"

                 output="${basedir}/bin-release/AppMonConfigWizard.swf" >

           <locale>en_US</locale>

            <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>

            <source-path path-element="${FLEX_HOME}/frameworks"/>

            <source-path path-element="${basedir}/src/locale/{locale}"></source-path>

            <compiler.library-path file="${basedir}/../wizard_framework/bin/wizard_framework.swc" append="true"/>

           <compiler.library-path file="${basedir}/../../utils/bin/utils.swc" append="true"/>

            <include-resource-bundles>ErrorMessages</include-resource-bundles>

            <include-resource-bundles>Strings</include-resource-bundles>

      </mxmlc>

       

      As mentioned earlier that following statements cause exception -

           myDataGrid.selectedItem = instanceTag;

           myDataGrid.dispatchEvent(new GridSelectionEvent(GridSelectionEvent.SELECTION_CHANGE));

       

      If I change it to

           myDataGrid.setSelectedIndex(<some index value>)   /*selectedItem replaced with setSelectedIndex*/

           myDataGrid.dispatchEvent(new GridSelectionEvent(GridSelectionEvent.SELECTION_CHANGE));

       

      it does not throw exception.  I would like to mention that myDataGrid.selectedItem = instanceTag; does sets the selected item but then in that case issue arises when dispatching event.

       

      I my application, similar statemetns were lot at many places (as there were no such issue with SDK 3.1 which was using earlier) so instead of making changes there, it would be better to imitate the build that Flex builder uses when exported the release build.

       

      Thanks in advance,

      Prithveesingh Zankat.