将 UIComponent 添加到 Flex 3 中的 Canvas 和 Tree
我目前正在尝试添加一个自定义类,该类将 UIComponent 子类化为树和画布,但是当我尝试通过拖动对树重新排序时,出现此错误:
TypeError: Error #1010: A term is undefined and has no特性。 在 mx.controls::Tree/get firstVisibleItem()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\Tree.as:764] 在 flash.utils::ByteArray/writeObject() 在 flash.desktop::Clipboard/putSerialization() 在 flash.desktop::Clipboard/convertFlashFormat() 在 flash.desktop::Clipboard/setData() 在 mx.managers::NativeDragManagerImpl/doDrag()[C:\autobuild\3.2.0\frameworks\projects\airframework\src\mx\managers\NativeDragManagerImpl.as:282] 在 mx.managers::DragManager$/doDrag()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\DragManager.as:243] 在 mx.controls.listClasses::ListBase/dragStartHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:9085] 在 flash.events::EventDispatcher/dispatchEventFunction() 在 flash.events::EventDispatcher/dispatchEvent() 在 mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298] 在 mx.controls.listClasses::ListBase/mouseMoveHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:8822]
当我不添加 UIComponent 时到画布上,不会发生此错误,任何人都知道为什么会发生这种情况?
I currently am trying to add a custom class which subclasses UIComponent to both a tree and a canvas, but when I try to re-order the tree by dragging I get this error:
TypeError: Error #1010: A term is undefined and has no properties.
at mx.controls::Tree/get firstVisibleItem()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\Tree.as:764]
at flash.utils::ByteArray/writeObject()
at flash.desktop::Clipboard/putSerialization()
at flash.desktop::Clipboard/convertFlashFormat()
at flash.desktop::Clipboard/setData()
at mx.managers::NativeDragManagerImpl/doDrag()[C:\autobuild\3.2.0\frameworks\projects\airframework\src\mx\managers\NativeDragManagerImpl.as:282]
at mx.managers::DragManager$/doDrag()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\managers\DragManager.as:243]
at mx.controls.listClasses::ListBase/dragStartHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:9085]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9298]
at mx.controls.listClasses::ListBase/mouseMoveHandler()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:8822]
When I do not add the UIComponent to the canvas, this error does not occur, anyone have any knowledge as to why this happens?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您收到此错误的原因是树或画布无法访问您的自定义组件属性或方法。尽管您的组件确实进入了显示对象,但它仍然需要知道如何访问它。
The reason you are getting this error, the tree or canvas is not able to access your custom components properties or methods. Though your component does get into the display object, but still it does need know on how to access it.
您应该创建控件的新实例,以便将其添加到画布中。 UIComponent 上有许多属性要求其位于一个位置 - 例如
parent
属性。如果您需要两者显示类似的内容,则可以使用第三个对象来存储状态并对其进行数据绑定。You should create a new instance of your control in order to add it to the canvas. There are numerous properties on a UIComponent that require it to be in one place - the
parent
property, for example. If you need both to display something similar, you can use a third object to store your state and databind to it.