让SuperTabNavigator支持NavigatorContent
作者:Flying 日期:2010-05-30
flexlib已经升级到Flex 4了,最近有用到SuperTabNavigator。我用NavigatorContent作为其子容器,结果出错:TypeError: Error #1009: 无法访问空对象引用的属性或方法。at flexlib.containers::SuperTabNavigator/reorderTabList()[E:\Exercise\Flex\Tutorials\Demo\src\flexlib\containers\SuperTabNavigator.as:1181]。
我花了一点时间解决了修正了这个Bug。打开SuperTabNavigator.as源码,定位到1181行附近。
var child:Container = this.getChildAt(i) as Container; var obj:Object = new Object(); //setting the type to an empty string bypasses a bug in MenuItemRenderer (or in //DefaultDataDescriptor, depending on how you look at it). Try commenting out the //line and check out the menu items. obj.type = ""; obj.label = (child.label != "") ? child.label : "Untitled Tab"; obj.icon = child.icon;
原来是将child的类型由NavigatorContent强制转化成Container时失败,child为null,当然无法访问其label属性。在Flex 4中,Container和NavigatorContent都实现INavigatorContent接口,因此只要将child的类型由Container改为INavigatorContent就可以支持NavigatorContent了。
上一篇: 使用Flex Chart画移动平均线
下一篇: 使用externalInterface.addCallback()容易犯的两个错误
文章来自: 本站原创
Tags: Flex4 Container
相关日志:
评论: 2 | 引用: 0 | 查看次数: -
发表评论


|
| 123.15.40.245 |
| 取消审核 |
回复]