flexlib2.5-flex4在使用SuperTabNavigator时的错误解决
【错误提示】
TypeError: Error #1009: 无法访问空对象引用的属性或方法。
at flexlib.containers::SuperTabNavigator/reorderTabList()[/Users/groumly/Development/workspace-3.5-flex4/FlexLib/src/flexlib/containers/SuperTabNavigator.as:1181]
at Function/http://adobe.com/AS3/2006/builtin::apply()
at mx.core::UIComponent/callLaterDispatcher2()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:11354]
at mx.core::UIComponent/callLaterDispatcher()[E:\dev\4.0.0\frameworks\projects\framework\src\mx\core\UIComponent.as:11292]
【原因剖析】
SuperTabNavigator中1181行child为null即使用了,null的原因是由NavigatorContent强制转化成Container时失败。在Flex 4中,Container和NavigatorContent都实现INavigatorContent接口,因此只要将child的类型由Container改为INavigatorContent就可以支持NavigatorContent了。
【解决方法】
重新编译flexlib,编译方法见本blog的文章
修改内容:在Flex 4中,Container和NavigatorContent都实现INavigatorContent接口,因此只要将child的类型由Container改为INavigatorContent就可以支持NavigatorContent了。SuperTabNavigator.as文件1174行左右修改如下:
for (var i:int = 0; i < this.numChildren; i++)
{
-// var child:Container = this.getChildAt(i) as Container;
+ var child:INavigatorContent = this.getChildAt(i) as INavigatorContent;
var obj:Object = new Object();
//setting the type to an empty string bypasses a bug in MenuItemRenderer (or in
【参考页面】
http://code.google.com/p/flexlib/issues/attachmentText?id=301&aid=837212459511001135&name=INavigatorContent.patch&token=-ZFl9Ym_S2zno52YdXbymnbt1es%3A1333329878543
http://www.riafan.com/article/flex/supertabnavigator-flex-4.html