在做项目的过程中,用到了module
但是在module加载的时候,unloading一个包含有ViewStack的module时出现错误如下:
TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::HistoryManagerImpl@ac6f8c1 to mx.managers.IHistoryManager.
at mx.managers::HistoryManager$/get impl()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\HistoryManager.as:101]
at mx.managers::HistoryManager$/unregister()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\HistoryManager.as:164]
at mx.containers::ViewStack/removedFromStageHandler()[E:\dev\4.5.1\frameworks\projects\mx\src\mx\containers\ViewStack.as:1308]
at flash.display::DisplayObjectContainer/removeChild()
at mx.core::UIComponent/http://www.adobe.com/2006/flex/mx/internal::$removeChild()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:7294]
at mx.core::UIComponent/removeChild()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core\UIComponent.as:7201]
at spark.components::Group/http://www.adobe.com/2006/flex/mx/internal::elementRemoved()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\Group.as:1679]
at spark.components::Group/removeElementAt()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\Group.as:1426]
at spark.components::Group/removeElement()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\Group.as:1404]
at spark.modules::ModuleLoader/unloadModule()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\modules\ModuleLoader.as:638]
at ui.content::AcceleratorContent/load()[D:\backup\rds\RDSMobile\src\ui\content\AcceleratorContent.mxml:23]
at ui.content::Content/select()[D:\backup\rds\RDSMobile\src\ui\content\Content.mxml:44]
at UIManager/selectObject()[D:\backup\rds\RDSMobile\src\UIManager.as:79]
at UIManager$/selectObject()[D:\backup\rds\RDSMobile\src\UIManager.as:164]
at com.sap.rdssbs.controller::StepController/selectStep()[D:\backup\rds\RDSMobile\src\com\sap\rdssbs\controller\StepController.as:84]
at ui.stepNavigation::AcceleratorItemRenderer/itemrenderer1_clickHandler()[D:\backup\rds\RDSMobile\src\ui\stepNavigation\AcceleratorItemRenderer.mxml:72]
at ui.stepNavigation::AcceleratorItemRenderer/___AcceleratorItemRenderer_ItemRenderer1_click()[D:\backup\rds\RDSMobile\src\ui\stepNavigation\AcceleratorItemRenderer.mxml:6]
我的页面结构如下:
在main页面:
<fx:Script>
<![CDATA[
import mx.managers.HistoryManager;
......
private var historyManager:HistoryManager;
public function load():void {
moduleLoader.unloadModule();
moduleLoader.loadModule("" + stepData.file);
}
public function refresh():void
{
this.load();
}
protected function group1_creationCompleteHandler(event:Event)
{
refresh();
}
]]>
</fx:Script>
<s:Group width="100%" height="100%">
<s:layout>
<s:VerticalLayout paddingLeft="20" paddingRight="20" paddingTop="10" paddingBottom="15" />
</s:layout>
<s:ModuleLoader id="moduleLoader" width="100%" height="100%" />
</s:Group>
其它的moduler a, b,c
module c中有viewstack.
在网上搜了一下,是个sdk的bug,其页面如下:
http://bugs.adobe.com/jira/browse/SDK-15249
和该问题相关的另外一个sdk的bug如下:
https://bugs.adobe.com/jira/browse/SDK-14384
解决办法就是如上红色加粗斜体的部分,在该页面加上一个HistoryManager的一个私有变量即可O(∩_∩)O~