views:

297

answers:

2

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?

A: 

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.

That doesn't seem to be the case, adding my custom UIComponent to either the canvas or tree works but not when added to both simultaneously.
Chris M
A: 

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.

Dan Monego
Well last night I went and did some extensive refactoring of my code to make the Object I am adding in to my tree a subclass of Object NOT UIComponent, then added a view property to my object that is then added to the canvas, which I thought would solve the problem, but the same error occurs. I have no idea why but it seems like the error has something to do with ByteArray::writeObject() when I have a uicomponent variable in my object. I really don't have time to look through all of flex's source code to debug it but for now I just disabled dragging until I can reorganize my code better.
Chris M