8 Replies Latest reply: Jun 27, 2012 7:42 AM by charanseeram RSS

    Type coertion DragEvent issue

    PhotoSì

      We are developing a new plugin for Photoshop, and we use the <mx:Window....> class to open a new modal window.
      Using this approach we always get problems when we try to use DragNDrop event on components like HorizontalList.

      Actually the main problem is concerning different version of the class DragEvent:

       

      TypeError: Error #1034: Type Coercion failed: cannot convert mx.events::DragEvent@15fe9581 to mx.events.DragEvent.
          at flash.events::EventDispatcher/dispatchEventFunction()
          at flash.events::EventDispatcher/dispatchEvent()
          at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.4.0\frameworks\projects\framework\src\mx\core\UIComponent.as:9408]
          at mx.managers::NativeDragManagerImpl/_dispatchDragEvent()[C:\autobuild\galaga\frameworks\projects\airframework\src\mx\managers\NativeDragManagerImpl.as:625]
          at mx.managers::NativeDragManagerImpl/nativeDragEventHandler()[C:\autobuild\galaga\frameworks\projects\airframework\src\mx\managers\NativeDragManagerImpl.as:598]
      

       

      Now we have found a solution using compiler option:

       

      -includes=mx.managers.systemClasses.MarshallingSupport
      

       

      but we use CS Extension Builder based on Flex SDK 3.4 so it's not possible to use that option.

      Do you have any advise to fix that problem?

      Thanks

       

      Marco

        • 1. Re: Type coertion DragEvent issue
          Harbs. MVP

          Don't use the debugger...

           

          Harbs

          • 2. Re: Type coertion DragEvent issue
            Bob Stucky Adobe Employee

            I assume you're dragging to and from Photoshop from your panel?

             

            I have an extension that does that successfully using Flex 3.4, listening for NativeDragEvent. It's not part of a mx:Window component...

            • 3. Re: Type coertion DragEvent issue
              PhotoSì Community Member

              Thank you Bob, it works with NativeDragEvent.
              The only problem is that the HorizontalList doesn't show the lines indicator during the drag and drop operation, but i resolved creating by myself.

              • 4. Re: Type coertion DragEvent issue
                nam1490

                hi  PhotoSi,

                How you calculate drop position?

                • 5. Re: Type coertion DragEvent issue
                  PhotoSì Community Member

                  Actually all items on our list have an attribute "position" (handle by our methods). When the drop event is catch i can get the item where the drop is engaged....and then our attribute about the position.

                  did it help you?

                  • 6. Re: Type coertion DragEvent issue
                    nam1490 Community Member

                    how you got the item from list through nativeEvent?Actually i have used AdvancedDataGrid and i want drop position or item at drop position?

                    • 7. Re: Type coertion DragEvent issue
                      PhotoSì Community Member

                      simply every item on the list has a eventHandler: nativeDragDrop="dragDropHandler...(event, data.Position)" where data.Position is the Position of the element (we user indexOf(this) on the horizzontal list to get the right position).

                      We don't use DataGrid so i cannot help on that........

                      • 8. Re: Type coertion DragEvent issue
                        charanseeram Community Member

                        *** Security Sandbox Violation ***

                        SecurityDomain 'http://portip:8080/MyProject//servlet/ThumbDownloadServlet?fileName=179924 copy.tif&sessionId=NrzEsU-sPKY2ABZCGQ03CQ__.node1&assetId=385344&type=thumb' tried to access incompatible context 'app:/StageManager-2.5.swf'

                        path:http://portip:8080/MyProject//servlet/ThumbDownloadServlet?fileName=AD_demo_images.jpg&ses sionId=NrzEsU-sPKY2ABZCGQ03CQ__.node1&assetId=505678&type=thumb

                        TypeError: Error #1034: Type Coercion failed: cannot convert mx.events::DragEvent@1a4776d1 to mx.events.DragEvent.

                            at flash.events::EventDispatcher/dispatchEventFunction()

                            at flash.events::EventDispatcher/dispatchEvent()

                            at mx.core::UIComponent/dispatchEvent()[C:\autobuild\3.4.0\frameworks\projects\framework\src \mx\core\UIComponent.as:9408]

                            at mx.managers::NativeDragManagerImpl/_dispatchDragEvent()[C:\autobuild\galaga\frameworks\pr ojects\airframework\src\mx\managers\NativeDragManagerImpl.as:625]

                            at mx.managers::NativeDragManagerImpl/nativeDragEventHandler()[C:\autobuild\galaga\framework s\projects\airframework\src\mx\managers\NativeDragManagerImpl.as:598]

                        TypeError: Error #1034: Type Coercion failed: cannot convert mx.events::DragEvent@1a477661 to mx.events.DragEvent.

                         

                        Hi , i am even facing same problem, time being i manged with: myList.addEventListener(NativeDragEvent.NATIVE_DRAG_COMPLETE,onDragComplete);

                              But am looking for some parmanet solution for doDrop , some one help me understanding why this  :myList.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP,onDrop); is not firing ..

                         

                        public function imageDrop( event: NativeDragEvent ): void {           

                         

                                    trace( "Drop image target is: " + event.currentTarget.toString() );

                                    if ( event.clipboard.hasFormat( ClipboardFormats.FILE_LIST_FORMAT )||

                                        event.clipboard.hasFormat(ClipboardFormats.TEXT_FORMAT) ||

                                        event.clipboard.hasFormat(ClipboardFormats.URL_FORMAT)) {

                                        var fileList: Array = event.clipboard.getData( ClipboardFormats.FILE_LIST_FORMAT ) as Array;

                                        trace( "File List: " + fileList.toString() );

                                        if ( fileList.length > 0 ) {

                                            var f: DragFile = new DragFile( fileList[ 0 ] as flash.filesystem.File );

                                            if ( "jpgjpegpnggif".indexOf( f.extension.toLowerCase() ) > -1 ) {

                                                trace( "Loading file: " + f.nativePath );

                                                loadFile( f );                       

                                                return;

                                            }

                                            trace( "file is not an image" );

                                        } else {

                                            trace ( "fileList is empty" );

                                        }

                                    }

                                    if ( event.clipboard.hasFormat( ClipboardFormats.BITMAP_FORMAT ) ) {

                                        trace( "Dropping the bitmap" );

                                        var bitmapData: BitmapData = event.clipboard.getData( ClipboardFormats.BITMAP_FORMAT ) as BitmapData;

                                        var bitMap: Bitmap = new Bitmap( bitmapData );

                                        model.imageCollection.addItem( bitMap );

                                        model.selectedIndex = model.imageCollection.length - 1;

                                    }           

                                }