So I have some code (below) that clones an arrayCollection. It works the first 
time through doesn't work the next time through.  The objects that are getting 
cloned are a custom object called "Node". So my AC has a list of Nodes in it.  
The first time the clone returns an Object of type:Object (so pass in Nodes out 
comes Objects).  The second time through I pass in another list of Nodes and 
out comes Nodes. Not what I want.

Why would the code below spit out two different things?  I have debugged this 
and walked it through and yes I know nodes are going in each time.

private function clone( source:Object ) :*
                        {
                                var myBA:ByteArray = new ByteArray();
                                myBA.writeObject( source );
                                myBA.position = 0;
                                return( myBA.readObject() );
                        }
                        
                        
                        private function buildTreeCollection( 
ac:ArrayCollection ) : void
                        {
                                var newAC:ArrayCollection = new 
ArrayCollection( clone( ac.source ) );
                                // add checked to all leaf objects
                                for each( var o:Object in newAC ){
                                        o.checked = 0;
                                } 
                                
                                _sortedTreeCollection = new TreeCollection( 
newAC );
                                // add checked to all folder objects
                                for each ( var ob:Object in 
_sortedTreeCollection ) {
                                        ob.checked = 0;
                                }
                                trace('');
                                //myTree.dataProvider = tree;
                                if( _sortedTreeCollection.length > 0 ) { 
                                        typeTree.visible = true; 
                                        typeTree.includeInLayout = true;
                                }
                                //this.height = Math.max( 150, 
typeTree.measureHeightOfItems(0, _sortedTreeCollection.length) + this.height );
                                
                        }

Reply via email to