让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;

popupMenuDP.addItem(obj);

原来是将child的类型由NavigatorContent强制转化成Container时失败,child为null,当然无法访问其label属性。在Flex 4中,Container和NavigatorContent都实现INavigatorContent接口,因此只要将child的类型由Container改为INavigatorContent就可以支持NavigatorContent了。

来源文章来自: 本站原创
引用通告引用通告: 查看所有引用 | 我要引用此文章
标签Tags: Flex4 Container Debug
相关日志相关日志:
评论: 1 | 引用: 0 | 查看次数: -
回复 回复引用孔楠[2010-06-01 01:30 PM | del ]
你好我在开发flex 4的时候使用了 spark.components.ComboBox,然而它却不能输入中文,不能切换到中文输入法。
您是否也遇到这个问题了?

QQ:287839128
真实姓名:孔楠
欢迎探讨。
回复来自 Flying 的评论 Flying 于 2010-06-03 01:14 PM 回复
Spark ComboBox是不支持中文输入法的,要么用Flex 3中的ComboBox,要么自己开发一个类似的组件。
发表评论
昵 称:
密 码: 游客发言不需要密码.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.