Could be a bug.  I don't understand why you re-set openItems after
re-adding the Tree to the display list.  I doubt we tested under those
conditions.  What happens if you don't reset openItems.

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of ivo
Sent: Wednesday, March 05, 2008 1:42 PM
To: [email protected]
Subject: Re: [flexcoders] How to maintain a Tree opened/close state
after removed/added to stage?

 

Not sure where to go with this next.

The following kinda works...the Tree listens for Event.ADDED_TO_STAGE
then go thru:

var _opened:Array = (m_tree.openItems as Array).concat([]);
tree.openItems = [];
callLater(reOpenItems, [_opened]);

...then in reOpenItems just:

m_tree.openItems = _opened;

..the above works as long as the Tree is kept with the branches in their
initial open/closed state. So the first time the Tree is shown a certain
set of initial branches are opened...the user dismisses the Tree...I
remove it from the display....the user asks for the Tree view again...I
readd the Tree & the above code runs & everything is ok as all its open
like it was initially.

But if the user requests the Tree...closes a branch (or
branches)...dismisses the Tree..then later requests the Tree..I get an
exception:

TypeError: Error #1010: A term is undefined and has no properties.
    at
mx.controls::List/createItemRenderer()[E:\dev\3.0.x\frameworks\projects\
framework\src\mx\controls\List.as:1796]
    at
mx.controls::List/http://www.adobe.com/2006/flex/mx/internal::getMeasuri
ngRenderer()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\controls\
List.as:1734
<http://www.adobe.com/2006/flex/mx/internal::getMeasuringRenderer%28%29%
5BE:%5Cdev%5C3.0.x%5Cframeworks%5Cprojects%5Cframework%5Csrc%5Cmx%5Ccont
rols%5CList.as:1734> ]
    at
mx.controls::List/commitProperties()[E:\dev\3.0.x\frameworks\projects\fr
amewo! rk\src\mx\controls\List.as:764]
    at
mx.controls::Tree/commitProperties()[E:\dev\3.0.x\frameworks\projects\fr
amework\src\mx\controls\Tree.as:1028]
    at
mx.core::UIComponent/validateProperties()[E:\dev\3.0.x\frameworks\projec
ts\framework\src\mx\core\UIComponent.as:5670]

...the line \framework\src\mx\controls\List.as:1796 sez:

delete freeItemRenderersByFactory[factory][renderer];

and there really isnt a value for freeItemRenderersByFactory[factory] .
The var freeItemRenderersByFactory does contain a single element
Dictionary but the debugger wont reveal what its contents are.

What can cause this condition?



- Ivo



----- Original Message ----
From: ivo <[EMAIL PROTECTED]>
To: f! [EMAIL PROTECTED]
Sent: Wednesday, March 5, 2008 11:47:01 AM
Subject: [flexcoders] How to maintain a Tree opened/close state after
removed/added to stage?

Hello all,

There is a behavior that is not apparent when building against Flex 3
beta 3 but shows up of Flex 3 release.

I have a Tree that is added/removed from the stage at various times. In
Beta 3 if I remove it from the display list & add it back at a later
time the tree is with the branches opened/closed as they were when it
was removed.

In the Flex Release the Tree always has all the branches closed once it
is added to the stage. Looking at the Tree properties shows
Tree.openItems does have a correct list of open branches. Iterating over
this list to to open them, or close then open, or saving this list when
removedFromStage and setting it again on addedToStage, or invalidating
the display list does not do anything. My next shot is simulating mouse
clicks on the renderers travelling from the outermost branches inward
but this feels like overkill.

Any suggestions on how to trigger the display so it matched the internal
open/closed state?

Thanks,

- Ivo

 

 

Reply via email to