6 Replies Latest reply on Mar 19, 2012 6:42 AM by lee704

    ActionScript Error on MenuBar click event after migrating to Flex 4.5.1

    lee704 Level 1

      Now that I have converted my app to Flex 4.5.1, a MenuBar click event throws the following error:

       

      TypeError: Error #2007: Parameter child must be non-null.

                at flash.display::DisplayObjectContainer/getChildIndex()

                at mx.core::Container/getChildIndex()[E:\dev\4.5.1\frameworks\projects\mx\src\mx\core\Contai ner.as:2839]

                at mx.containers::ViewStack/set selectedChild()[E:\dev\4.5.1\frameworks\projects\mx\src\mx\containers\ViewStack.as:639]

                at com.views::publicCanvas/mouseClick()[C:\ColdFusion9\wwwroot\ifq2\src\com\views\publicCanv as.mxml:54]

                at com.views::publicCanvas/__menuBar_click()[C:\ColdFusion9\wwwroot\ifq2\src\com\views\publi cCanvas.mxml:86]

       

      The function throwing the error is:

       

      private function mouseClick(event:MouseEvent):void

      {

                var tempMenu:MenuBarItem=MenuBarItem(event.target)

       

                if (XMLList(tempMenu.data).*.length() == 0)

                {

                          publicViewStack.selectedChild=this[(MenuBarItem(event.target).data.@view)];

                }

      }

       

      The ViewStack is defined as:

       

      <mx:ViewStack id="publicViewStack"

                                      x="0"

                                      y="22"

                                      width="100%"

                                      height="564"

                                      selectedIndex="0">

       

       

                <!-- selectedIndex = 0 -->

                <s:NavigatorContent>

                          <views:publicHomeCanvas id="publicHomeCanvas"/>

                </s:NavigatorContent>

       

       

                <!-- selectedIndex = 1 -->

                <s:NavigatorContent>

                          <views:viewDealers id="viewDealers"/>

                </s:NavigatorContent>

       

      </mx:ViewStack>

       

      The menu data is defined in the menuDataPublic.as file as:

       

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

       

      <items>

       

                <item position="top" label="Home" view="publicHomeCanvas" menuindex="0" />

       

                <item position="top" label="View Dealers" view="viewDealers" menuindex="1" />

       

      </items>

       

      In 3.6, this worked perfectly.  Under 4.5.1 it fails as indicated.  Has anyone run into a similar problem?

       

      Thank again!

      Lee