I'm facing the same error:

TreeModelChangedEvent
TreeModelChangedEventDetail

don't exist anymore. Haven't find anything in the documentation, any
suggestion for this?.

Thanks,

Pepe.

--- In flexcoders@yahoogroups.com, "Bryan Choi" <[EMAIL PROTECTED]> wrote:
>
> MyCustomTreeDataDescriptor implements ITreeDataDescriptor, but it's
wrong.
> 
> ==================
> 
> package
> {
> import mx.collections.ICollectionView;
> import mx.collections.IViewCursor;
> import mx.events.TreeModelChangedEvent;
> import mx.events.TreeModelChangedEventDetail;
> import mx.controls.treeClasses.*;
> 
> public class MyCustomTreeDataDescriptor implements ITreeDataDescriptor
> {
> 
>     // The getChildren method requires the node to be an Object
>     // with a children field.
>     // If the field contains an ArrayCollection, it returns the field
>     // Otherwise, it wraps the field in an ArrayCollection.
>     public function getChildren(node:Object,
>         model:Object=null):ICollectionView
>     {
>         try
>         {
>             if (node is Object)
>             {
> 
>                 if(node.children is ArrayCollection){
>                     return node.children;
>                 }else{
>                     return new ArrayCollection(node.children);
>                 }
>             }
>         }
>         catch (e:Error)
>         {
>             trace("[Descriptor] exception checking for getChildren");
> 
>         }
>         return null;
>     }
> 
>     // The isBranch method simply returns true if the node is an
>     // Object with a children field.
>     // It does not support empty branches, but does support null
children
>     // fields.
>     public function isBranch(node:Object, model:Object=null):Boolean
>     {
>         try
>         {
>             if (node is Object)
>             {
>                 if (node.children != null)
>                 {
>                     return true;
>                 }
>             }
>         }
>         catch (e:Error)
>         {
>             trace("[Descriptor] exception checking for isBranch");
>         }
>         return false;
>     }
> 
>     // The getData method simply returns the node as an Object.
>     public function getData(node:Object, model:Object=null):Object
>     {
>         try
>         {
>             return Object(node);
>         }
>         catch (e:Error)
>         {
>         }
>         return null;
>     }
> 
>     // The addChildAt method does the following:
>     // If the node parameter is null or undefined, inserts
>     // the child parameter as the first child of the model parameter.
>     // If the node parameter is an Object and has a children field,
>     // adds the child parameter to it at the index parameter location.
>     // It does not add a child to a terminal node if it does not have
>     // a children field.
>     public function addChildAt(node:Object, child:Object, index:int,
model:Object=null):Boolean
>     {
>         var event:TreeModelChangedEvent = new
TreeModelChangedEvent("modelChanged", false, false,
TreeModelChangedEventDetail.ADD_NODE, child, node, index);
> 
>         if (!node)
>         {
>             var iterator:IViewCursor = model.createCursor();
>             iterator.seek(CursorBookmark.FIRST, index);
>             iterator.insert(child);
>         }
>         else if (node is Object)
>         {
>             if (node.children != null)
>             {
>                 if(node.children is ArrayCollection) {
>                     node.children.addItemAt(child, index);
>                     if (model){
>                         model.dispatchEvent(event);
>                         model.itemUpdated(node);
>                     }
>                     return true;
>                 }
>                 else {
>                     node.children.splice(index, 0, child);
>                     if (model)
>                         model.dispatchEvent(event);
>                     return true;
>                 }
>             }
>         }
>         return false;
>     }
> 
> }
> }
> The following example code uses the MyCustomTreeDataDescriptor to
handle hierarchal nested ArrayCollections and objects. When you click
the button it adds a node to the tree by calling the data descriptor's
addChildAt method.
> 
> <?xml version="1.0" encoding="iso-8859-1"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
creationComplete="initCollections()">
> 
>     <mx:Script>
>         <![CDATA[
>             import mx.collections.*;
>             import mx.controls.treeClasses.*;
>     
>             //Variables used to construct the ArrayCollection data
provider
>             //First top-level node and its children.
>             public var nestArray1:Object = [
>                 {label:"item1", children: [
>                     {label:"item1 child", children:     [
>                         {label:"item 1 child child", data:"child data"}
>                     ]}
>                 ]}
>             ]; 
>             //Second top-level node and its children.
>             public var nestArray2:Object = [
>                 {label:"item2", children: [ 
>                     {label:"item2 child", children: [
>                         {label:"item 2 child child", data:"child data"}
>                     ]}
>                 ]}
>             ];
>             //Second top-level node and its children.
>             public var nestArray3:Object = [
>                 {label:"item3", children: [
>                     {label:"item3 child", children: [
>                         {label:"item 3 child child", data:"child data"}
>                     ]}
>                 ]}
>             ]; 
>             //Variable for the tree array.
>             public var treeArray:Object
>             //Variables for the three Array collections that
correspond to the 
>             //top-level nodes.
>             public var col1:ArrayCollection;
>             public var col2:ArrayCollection;
>             public var col3:ArrayCollection;
>             //Variable for the ArrayCollection used as the Tree data
provider.
>             [Bindable]
>             public var ac:ArrayCollection;
>             
>             //build the ac ArrayCollection from its parts.
>             public function initCollections():void{
>                 // Wrap each top-level node in an ArrayCollection.
>                 col1 = new ArrayCollection(nestArray1);
>                 col2 = new ArrayCollection(nestArray2);
>                 col3 = new ArrayCollection(nestArray3);
>                 // Put the three top-level node ArrayCollections in
the treeArray.
>                 treeArray = [
>                     {label:"first thing", children: col1},
>                     {label:"second thing", children: col2},
>                     {label:"third thing", children: col3},
>                 ]; 
>                 //Wrap the treeArray in an ArrayCollection.
>                 ac = new ArrayCollection(treeArray);
>             }
> 
>             // Adds a child node as the first child of the selected
node,
>             // if any. The default selectedNode is null, which
causes the
>             // data descriptor addChild method to add it as the
first child
>             // of the ac ArrayCollection.
>             public function clickAddChildren():void {
>                 var newChild:Object = new Object();
>                 newChild.label = "New Child";
>                 newChild.children = new ArrayCollection();
>                
tree.treeDataDescriptor.addChildAt(tree.selectedNode, newChild, 0, ac);
>             }
> 
>         ]]>
>     </mx:Script>
> 
>     <mx:Tree width="200" id="tree" dataProvider="{ac}" 
>         treeDataDescriptor="{new MyCustomTreeDataDescriptor()}"/>  
 <------------ this is an error
>     <mx:Button label="add children" click="clickAddChildren()"/>
> </mx:Application>
> ====================You can see that error message follow, if you
run above application.-> Severity Description Resource In Folder
Location Creation Time Id2 Cannot resolve attribute
'treeDataDescriptor' for component type mx.controls.Tree.
AppMyCustomTreeDataDescriptor.mxml ShinhanBank_Local line 76 2006³â
5¿ù 18ÀÏ (¸ñ) ¿ÀÈÄ 2:07:36 47I couldn't find the property of
treeDataDescriptor from the help.However, I found a property named
dataDescriptor for the component fo Tree.But, I couldn't see that
perform well even if use it.Please, help me. anybody no idea?
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Protect your PC from spy ware with award winning anti spy technology. It's free.
http://us.click.yahoo.com/97bhrC/LGxNAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to