I did the same as you did and it works fine....

main.mxml:
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; width="700"
height="250"
borderStyle="solid" creationComplete="CallMeNow()">
     <mx:Script>
         <![CDATA[
             import com.CallTree;

             public function CallMeNow():void
             {
                 var t:CallTree = new CallTree();
                 addChild(t);
             }
         ]]>
     </mx:Script>
</mx:Application>

CallTree.mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml";>
     <mx:Script>
         <![CDATA[
             // Initialize the data provider for the Tree.
             private function initApp():void
             {
                 firstList.dataProvider = treeDP;
             }
         ]]>
     </mx:Script>
     <mx:XML id="treeDP">
         <node label="Mail">
         <node label="Inbox"/>
         <node label="Personal Folder">
         <node label="Demo"/>
         <node label="Personal"/>
         <node label="Saved Mail"/>
         <node label="bar"/>
         </node>
         <node label="Calendar"/>
         <node label="Sent"/>
         <node label="Trash"/>
         </node>
     </mx:XML>
     <mx:Tree id="firstList" height="200" width="200" showRoot="false"
         labelField="@label" dragEnabled="true" dropEnabled="true"
dragMoveEnabled="true"
         allowMultipleSelection="true" creationComplete="initApp();"/>
</mx:Canvas>



--- In [email protected], "timgerr" <tgallag...@...> wrote:
>
> OK, Here is what I did.  I wanted to know if there was a problem with
my code or was it the tree stuff.  I went to Adobe Live Docs to get a
tree example
(http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhe\
lp.htm?context=LiveDocs_Book_Parts&file=dragdrop_081_06.html).  I took
this code and created a Canvas Component from it.  I then created an app
and called the code from it.
>
> I then called the app and when I click on any of the items in the tree
I get this error:
> ArgumentError: Error #2025: The supplied DisplayObject must be a child
of the caller.
>  at flash.display::DisplayObjectContainer/getChildIndex()
>  at
mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.2.0\frameworks\
\projects\framework\src\mx\managers\SystemManager.as:1652]
>  at
mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.2.0\framewo\
rks\projects\framework\src\mx\managers\SystemManager.as:3439]
>
> Here is the code that I used for the component CallTree.mxml:
>
> [CODE]
> <?xml version="1.0"?>
> <!-- dragdrop\SimpleTreeSelf.mxml -->
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>     width="700" height="250"
>     borderStyle="solid">
>
>     <mx:Script>
>         <![CDATA[
>             // Initialize the data provider for the Tree.
>             private function initApp():void {
>                 firstList.dataProvider = treeDP;
>             }
>         ]]>
>     </mx:Script>
>
>     <mx:XML id="treeDP">
>         <node label="Mail">
>             <node label="Inbox"/>
>             <node label="Personal Folder">
>                 <node label="Demo"/>
>                 <node label="Personal"/>
>                 <node label="Saved Mail"/>
>                 <node label="bar"/>
>             </node>
>             <node label="Calendar"/>
>             <node label="Sent"/>
>             <node label="Trash"/>
>         </node>
>     </mx:XML>
>
>     <mx:Tree id="firstList"
>         height="200" width="200"
>         showRoot="false"
>         labelField="@label"
>         dragEnabled="true"
>         dropEnabled="true"
>         dragMoveEnabled="true"
>         allowMultipleSelection="true"
>         creationComplete="initApp();"/>
> </mx:Application>
> [/CODE]
>
> Here is the application that is calling CallTree.mxml
> [CODE]
> <?xml version="1.0"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
>     width="700" height="250"
>     borderStyle="solid"
>     creationComplete="CallMeNow()">
>  <mx:Script>
>   <![CDATA[
>    import com.callTree;
>
>    public function CallMeNow():void
>    {
>     var t:callTree = new callTree()
>     addChild(t);
>    }
>   ]]>
>  </mx:Script>
> </mx:Application>
> [/CODE]
>
> I am not sure what to do here.
>
> Thanks for the read,
> timgerr
>

Reply via email to