5 Replies Latest reply on Sep 29, 2011 2:48 PM by Jason Szeto

    Drag n drop, img proxy doesn't show up

    Kywhod

      Hi all,

       

      I have a list which contains items with a specific itemrenderer. Objects contains iconPath:String, imagePath:String and label:String. My renderer shows an icon followed by a label. And when i click on the renderer to drag it to another panel I want to show up an image (provided by imagePath).

      Here is my code :

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"

                          xmlns:s="library://ns.adobe.com/flex/spark"

                          xmlns:mx="library://ns.adobe.com/flex/mx"

                          autoDrawBackground="true"

                          mouseDown="itemrenderer1_mouseDownHandler(event)">

          

           <fx:Script>

                <![CDATA[

                     import flash.utils.setTimeout;

                    

                     import mx.core.DragSource;

                     import mx.managers.DragManager;

                    

                     protected function itemrenderer1_mouseDownHandler(event:MouseEvent):void {

                          var dragInitiator:ItemRenderer = ItemRenderer(event.currentTarget);

                          var ds:DragSource = new DragSource();

                          var imageProxy:Image = new Image();

                          imageProxy.source = data.imagePath;

                          imageProxy.height = 100;

                          imageProxy.width = 100;

                          DragManager.doDrag(dragInitiator, ds, event, imageProxy);

                     }

                ]]>

           </fx:Script>

          

           <s:HGroup height="50">

                <s:Image source="{data.iconPath}"/>

                <s:Label text="{data.name}"/>

           </s:HGroup>

          

      </s:ItemRenderer>

       

       

      What happen : The proxy image doesn't show up.

      Why? imagePath is correct, with a specified width and height (just for test but after i want real values here), what i'm doing wrong ?

       

      Thanks for any help,

      Best, Ky.

        • 1. Re: Drag n drop, img proxy doesn't show up
          Kywhod Level 1

          no hint for this issue ?

           

          Thanks,

          Ky

          • 2. Re: Drag n drop, img proxy doesn't show up
            Shongrunden Adobe Employee

            Can you please provide a complete, compilable sample application that demonstrates this issue?

            • 3. Re: Drag n drop, img proxy doesn't show up
              Kywhod Level 1

              Thanks for the reply,

               

              Here is a complete sample that demonstrate the issue.

              http://dl.free.fr/jkcJaGSVQ

              See install.txt (you juste have to put the 2 image file in the application file directory)

              I remain available for any further information,

               

              Thanks for helping me on that

              Ky.

              • 4. Re: Drag n drop, img proxy doesn't show up
                Shongrunden Adobe Employee

                Here's a simplified version of the project in the RAR file:

                <s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"

                                       xmlns:s="library://ns.adobe.com/flex/spark">

                    <fx:Script>

                        <![CDATA[

                            import mx.events.DragEvent;

                            import mx.managers.DragManager;

                 

                            protected function panel1_dragEnterHandler(event:DragEvent):void {

                                DragManager.acceptDragDrop(Panel(event.currentTarget));

                            }

                        ]]>

                    </fx:Script>

                 

                    <s:layout>

                        <s:HorizontalLayout/>

                    </s:layout>

                 

                    <s:List width="50%" height="100%">

                        <s:dataProvider>

                            <s:ArrayList>

                                <fx:Object name="test" iconPath="buttonicon.png" />

                            </s:ArrayList>

                        </s:dataProvider>

                        <s:itemRenderer>

                            <fx:Component>

                                <s:ItemRenderer mouseDown="itemrenderer1_mouseDownHandler(event)">

                                    <fx:Script>

                                        <![CDATA[

                                            import mx.core.DragSource;

                                            import mx.managers.DragManager;

                 

                                            protected function itemrenderer1_mouseDownHandler(event:MouseEvent):void {

                                                var dragInitiator:ItemRenderer = ItemRenderer(event.currentTarget);

                                                var ds:DragSource = new DragSource();

                                                ds.addData(true, "newwidget");

                                                ds.addData(data.imagePath, "source");

                                                DragManager.doDrag(dragInitiator, ds, event, imageProxy);

                                            }

                                        ]]>

                                    </fx:Script>

                                    <fx:Declarations>

                                        <s:Image id="imageProxy" width="100" height="100" source="buttonicon.png" />

                                        <s:Image id="imageProxyEmbedded" width="100" height="100" source="@Embed('buttonicon.png')" />

                                    </fx:Declarations>

                                    <s:Label text="{data.name}" height="100"/>

                                </s:ItemRenderer>

                            </fx:Component>

                        </s:itemRenderer>

                    </s:List>

                 

                    <s:Panel width="50%" height="100%" dragEnter="panel1_dragEnterHandler(event)" />

                 

                </s:WindowedApplication>

                 

                It looks like this works when you use an embedded image as your imageProxy, but not when the image source is not embedded.  It seems to me like you should be able to use either embedded or referenced images and have filed a bug for that here: https://bugs.adobe.com/jira/browse/SDK-31081