TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::HistoryManagerImpl@f22eee1
来源:互联网 发布:淘宝上有招聘唇模的么 编辑:程序博客网 时间:2024/06/05 20:45
最近发现了一个flex模块加载触发的dragManager的错误,在主application里面放上一个moduleLoader用来加载模块,放 置了两个按钮来控制重复加载,按下第一个按钮加载模块,按下另外一个按钮卸载模块,加载使用moduleLoader的load方法,卸载使用 unloadModule()方法,模块里放置了一个datagrid,测试过程中发现,当重新加载模块,也就是执行了一次unloadModule方法然后按第一个按钮重新加载模块,这个时候如果去点击datagrid里面任何一行都会出现:
TypeError: Error #1034: Type Coercion failed: cannot convert
mx.managers::DragManagerImpl@12631a61 转换为 mx.managers.IDragManager
这样的错误。在google找了很久,终于在一个国外的论坛上发现了解决的办法,很简单就是在主应用里面加上
import mx.managers.DragManager;
private var dragManager:DragManager;
这两句就可以解决问题。至于为什么会出现这样的情况,在网上找到别人的解释,以下是转自google一个flex 讨论组别人的回答(http: //groups.google.com/group/riadev/tree/browse_frm/month/2007-05/5eeebf64e4926c45? rnum=11&_done=%2Fgroup%2Friadev%2Fbrowse_frm%2Fmonth%2F2007-05%3F)
QUOTE:
这属于Module的共享代码问题(shared code),
当Module中使用managers时(如PopUpManager,DragManager, HistoryManager)容易出现这个问题,
manager的方法都是静态方法,整个应用程序中创建了一个该manager接口的singleton,
但module仅在自己的Application domain中使用该singleton, 当多个module使用同一个singleton且main
application没有使用时,就会出现这个空对象引用问题:首先引入某manager的module不能将该manager接口的singleton跟其
他module共享,其他module调用该Manager的方法时,应用程序不会再创建该manager接口的实例,这个module就无法引用到该manager接口的实例,就出现了空对象引用问题,可以参考Flex的源码。
默认情况下,Accordion和TabNavigator的 historyManagementEnabled =
true;而ViewStack的historyManagementEnabled = false;
所以使用TabNavigator和Accordion时要注意HistoryManager的共享代码问题。另,仅一个module使用HistoryManager时,卸载之后又加载该module也会出现该问题,说明第二次加载时相当于一个新的module了。
一个解决办法:
在main application 中引入相关manager,可以通过在main application中申明manager的引用即可,如:
import mx.managers.HistoryManager;
var historyManager:HistoryManager;
其他manager类似。
还可以将共享代码作为module加载到main applicaiton的application domain,具体讲解可以参考Alex
Harui的ppt:
http://blogs.adobe.com/aharui/presentations/ 下面关于module的presentation, 讲得很详细。
- TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::HistoryManagerImpl@f22eee1
- Flex程序TypeError: Error #1034: Type Coercion failed: cannot convert
- TypeError: Error #1034: 强制转换类型失败:无法将 mx.managers::HistoryManagerImpl@65a76c9 转换为 mx.managers.IHistor
- How to fix this issue: Type Coercion failed: cannot convert flash.events::Event@8eda061 to starling.
- TypeError: Cannot convert Type TensorType(float32, matrix).....
- Error #1034: 强制转换类型失败:无法将 mx.managers::DragManagerImpl@141c5b81 转换为 mx.managers.IDragManager。
- TypeError: Error #1034: 强制转换类型失败:无法将 mx.utils::ObjectProxy@32b2c11 转换为 mx.collections.ArrayCollection。
- Spring: Error Cannot convert value of type [$Proxy...] to required type
- Spring-aop: Error Cannot convert value of type [$Proxy...] to required type
- TypeError: Error #1034: 强制转换类型失败:无法将 "0.49" 转换为 mx.graphics.IFill。
- TypeError: cannot perform reduce with flexible type
- error C2440: 'type cast' : cannot convert from 'int *' to 'void (__thiscall CCmdTarget::*)(void)'解决
- The resolution of ERROR C2662: cannot convert 'this' pointer from "const Class-Type" to "Class&"
- TypeError: Error #1034: 强制转换类型失败:无法将 global@189ac0d1 转换为 mx.core.IFlexDisplayObject。
- TypeError: Error #1034: 强制转换类型失败:无法将 Object@2555f679 转换为 mx.messaging.messages.IMessage。
- TypeError: Error #1034: 强制转换类型失败:无法将 flash.events::MouseEvent@73b7cc1 转换为 mx.events.ItemClickEvent。
- TypeError: Error #1034: 强制转换类型失败:无法将 mx.controls::DataGrid@9a7c0a1 转换为 spark.core.IViewport。
- Scrapy - TypeError: Cannot convert unicode body - HtmlResponse has no encoding
- 《统计学习方法》(李航)的学习体会(一)
- 19. Crontab
- 20. Screen
- Handler,Looper,Message,HandlerMessage,Thread关系及区别
- 关于快排函数
- TypeError: Error #1034: Type Coercion failed: cannot convert mx.managers::HistoryManagerImpl@f22eee1
- OpenCV python学习笔记(五)
- 21. DNS 配置和端口检测
- 三元表达式、箭头函数
- How to install tftp-server on Fedora 25 workstation
- 使用Mybatis-Generator自动生成Dao、Model、Mapping相关文件(转)
- 22. 使用 awk / grep / head / tail 命令进行文本 / 日志分析
- 什么是crm
- 23. CURL 常用命令