I have to assume that if this works
 
var data:Object = event.dragSource.dataForFormat("treeItems");
trace("doDragDrop " + data[0].parent());
 
the xml or return object thinks no children exist there are only attributes not a full xml string value, so you have to access the attributes. I have not yet worked alot with the "mx:xml" object. Anyway i don't see what is really wrong with anything. In principle is should work.
 
below is a modified doDragDrop that works as you want it. It must be because there is no nested value, or the fact your not casting it to xml. Might be a bug but not sure how the mx:xml works internally.
 
private function doDragDrop(event:DragEvent):void {
            var data:Object = event.dragSource.dataForFormat('treeItems');
            trace("doDragDrop " + data[0].toString());
           
            var oxml:XML = XML(data[0]);
           
            trace(oxml.toXMLString());
           
            /*if(data is Array){
                  var a:Array = Array(data);
                  trace("isArray l " +  a.length);
                  trace("doDragDrop " + a[0].toString());
            }*/
        }
 
Anyway hope this helps, cheers
 
Jason
 
 
-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Jason Hawryluk
Envoyé : jeudi 23 février 2006 14:02
À : flexcoders@yahoogroups.com
Objet : RE: [flexcoders] Tree DragAndDrop no data for leaf

never mind i see now the leaf is the problem give me a couple secs
 
-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Jason Hawryluk
Envoyé : jeudi 23 février 2006 13:56
À : flexcoders@yahoogroups.com
Objet : RE: [flexcoders] Tree DragAndDrop no data for leaf

I really see no prob with this i traced
 

isArray l 1

doDragDrop <Title label="Intern">

<Name label="Kapil Virdi"/>

</Title>

Seems to work, what exactly are you expecting ? as a result other then the above

jason

 

-----Message d'origine-----
De : flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED]De la part de Sönke Rohde
Envoyé : jeudi 23 février 2006 11:57
À : flexcoders@yahoogroups.com
Objet : Re: [flexcoders] Tree DragAndDrop no data for leaf

Hi Matt,
This really looks like a bug. I have made a simple example. Try to drag the
leaf of the tree and there will be traced that the array has length 1 but
the trace of the item itself is empty.

Cheers,
Sönke

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2005/mxml"
layout="absolute">

      <mx:Script>
    <![CDATA[
        import mx.core.DragSource;
        import mx.managers.DragManager;
        import mx.events.*;
        import mx.containers.Canvas;
        import flash.util.trace;

        private function doDragEnter(event:DragEvent):void {
            var dropTarget:Canvas=Canvas(event.currentTarget);
            if (event.dragSource.hasFormat('treeItems')) {
                DragManager.acceptDragDrop(dropTarget);
            }
        }
               
        private function doDragDrop(event:DragEvent):void {
            var data:Object = event.dragSource.dataForFormat('treeItems');
            if(data is Array){
                  var a:Array = Array(data);
                  trace("isArray l " +  a.length);
                  trace("doDragDrop " + a[0].toString());
            }
        }
   
    ]]>
    </mx:Script>


      <!-- Simple example to demonstrate the Tree control -->
    <mx:XML id="myxml">
        <Company label="Macromedia">
            <Branch label="Newton">
                <Department label="Flex Doc">
                    <Title label="Intern">
                        <Name label="Kapil Virdi"></Name>
                    </Title>
                </Department>
            </Branch>
        </Company>
    </mx:XML>

      <mx:Tree x="34" y="39" height="375" id="tree" dragEnabled="true"
dataProvider="{myxml}" labelField="@label" width="194"></mx:Tree>
     
      <mx:Canvas x="378" y="39" width="200" height="200"
backgroundColor="0xffffff" id="canvas"
            dragEnter="doDragEnter(event);"
dragDrop="doDragDrop(event);" >
      </mx:Canvas>
     
</mx:Application>


> It may be a bug in the drag and drop code.  Can you send a test case?
>
> -----Original Message-----
> From: flexcoders@yahoogroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Sönke Rohde
> Sent: Wednesday, February 22, 2006 10:02 AM
> To: flexcoders@yahoogroups.com
> Subject: [flexcoders] Tree DragAndDrop no data for leaf
>
> Hi,
> I have got a problem getting the data of a dragged leaf from a tree.
> The DragEvent.DRAG_DROP is handled by the following function:
>
> private function doDrop(e:DragEvent):void{
>       var data:Object = e.dragSource.dataForFormat("treeItems");
>       trace("data " + data.toString());
> }
>
> The leaf which is dragged has this XML <node label="Test"
> data="" /> and
> nothing for the data is traced. When I drag a branch like:
> <node label="common">
>       <node label="Test" data=""/>
> </node>
> All is traced correctly.
>
>
> Why do I get no data for the leaf? Is the XML malformated?
>
> Thanks,
> Sönke
>
>
>
> --
> 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
>
>
>

>
>
>
>
> --
> 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
>
>
>

>
>
>
>



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




SPONSORED LINKS
Web site design development Computer software development Software design and development
Macromedia flex Software development best practice


YAHOO! GROUPS LINKS




Reply via email to