Flex 3:TypeError #2007 &深度链接
当应用程序启动时,我收到 Flex 错误 #2007。
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]
我正在尝试让深度链接正常工作。 Adobe Flex 论坛上的 Bhasker Chari 非常友善地帮助我编写了以下代码:
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;
}
基本上,我采用 browserManager.fragment,将其转换为字符串,用下划线替换破折号,将其转换为容器,然后使用它来在 mainViewStack 上设置 selectedChild。
但是,当它初始化时,它说没有子参数。我该如何解决这个问题?
谢谢。
-拉克斯米迪
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,
我明白了。我需要添加:
if(t!=null){mainViewStack.selectedChild = t}
else{mainViewStack.selectedIndex = 0}
子级尚未创建。
谢谢。
-拉克斯米迪
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