让SuperTabNavigator支持NavigatorContent

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了。

评论: 2 | 引用: 0 | 查看次数: -
引用lyz_k24[2011-10-25 01:21 PM | 无网站 | 无Mail | 123.15.40.245 | 删除 | 取消审核 | 回复回复]
[正在加载评论信息,请稍候...]
引用孔楠[2010-06-01 01:30 PM | 无网站 | 无Mail | 58.56.38.210 | 删除 | 取消审核 | 回复回复]
[正在加载评论信息,请稍候...]
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭