views:

9

answers:

1

Hi,

I'm getting Flex error #2007, right when the app starts up.

TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/getChildIndex()
    at mx.core::Container/getChildIndex()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2411]
    at mx.containers::ViewStack/set selectedChild()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\ViewStack.as:557]
    at property/parseUrl()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:8803]
    at property/initBrowserManager()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:8749]
    at property/___property_Application1_creationComplete()[/Users/myname/Documents/Flex Builder 3/property/src/property.mxml:19]

I'm trying to get deeplinking to work properly. Bhasker Chari on the Adobe Flex forum was kind enough to help me with the code below:

private function parseUrl(e:BrowserChangeEvent = null):void {


  var o:Object = URLUtil.stringToObject(browserManager.fragment);

  var j:Object = o.view;

  var f:String = String(j);

  var c:String = f.replace(/-/g,"_");

  var t:Container = mainViewStack.getChildByName(c) as Container;

  mainViewStack.selectedChild = t;
  }

Basically, I take the browserManager.fragment, convert it to a string, replace the dash with an underscore, convert it to a container, and use that to set the the selectedChild on the mainViewStack.

But, when it initializes, it says that there is no child parameter. How can I solve this problem?

Thank you.

-Laxmidi

A: 

Okay,

I figured it out. I need to add:

if(t!=null){mainViewStack.selectedChild = t} else{mainViewStack.selectedIndex = 0}

The children hadn't been created, yet.

Thank you.

-Laxmidi

Laxmidi