mardi 29 décembre 2015

Can not Get an Image URL When Drag and Drop an Image from IE8 Using "NativeDragEvent" into Flash

I have this code:

this.addEventListener(NativeDragEvent.NATIVE_DRAG_ENTER, onNativeDragEnter);

private function onNativeDragEnter(vEvent:NativeDragEvent)
{   
    httpUrl = vEvent.clipboard.getData( ClipboardFormats.URL_FORMAT ) as String;
    var arr:Array = (vEvent.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT)) as Array;

    if(arr != null && arr.length >= 1 || httpUrl != null && httpUrl.length > 3)
    {
        NativeDragManager.acceptDragDrop(this); 
        this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onNativeDragDrop);
    }
    else
    {
        if(vEvent.clipboard.hasFormat(ClipboardFormats.TEXT_FORMAT))
        {
            DragManager.acceptDragDrop(this);
            this.addEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onNativeDragDropForText);
        }
    }

    arr = null;
}

private function onNativeDragDrop(vEvent:NativeDragEvent)
{
    var dropFiles:Array = vEvent.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array;

    if(httpUrl == null)
    {
        for(var i=0;i<dropFiles.length;i++)
        {
            var dragDropEvent:MediaManagerEvents = new MediaManagerEvents(MediaManagerEvents.DRAG_DROP_MEDIA);
            dragDropEvent.fileURL = (dropFiles[i] as File).nativePath;
            dispatchEvent(dragDropEvent);
        }
    }
    else 
    {
        var extension = getExtension(httpUrl);
        var scopeCount = getMatchCount(":",httpUrl);
        if (scopeCount <= 1 && ( extension == 'gif' || extension == 'jpg' || extension == 'png' || extension == 'JPEG' || extension == 'jpeg' || extension == 'JPG' || extension == 'PNG' || extension == 'bmp' || extension == 'BMP'))
        {
            var dragDropEvent:MediaManagerEvents = new MediaManagerEvents(MediaManagerEvents.DRAG_DROP_MEDIA);
            dragDropEvent.fileURL = httpUrl;
            dispatchEvent(dragDropEvent);
        }
        else if(dropFiles && dropFiles.length > 0)
        {
            var original:File = File(dropFiles[0]);
            var nativeExtension = getExtension(original.nativePath);

            if(nativeExtension == 'bmp' || nativeExtension == 'BMP'){
                var loader:URLLoader = new URLLoader();         
                loader.dataFormat = URLLoaderDataFormat.BINARY;         
                loader.addEventListener( Event.COMPLETE, onCompleteLoad );          
                loader.load( new URLRequest( original.nativePath ) );
            }
            else{
                var dragDropEvent:MediaManagerEvents = new MediaManagerEvents(MediaManagerEvents.DRAG_DROP_MEDIA);
                dragDropEvent.fileURL = original.nativePath;
                dispatchEvent(dragDropEvent);
            }
        }
    }

    this.removeEventListener(NativeDragEvent.NATIVE_DRAG_DROP, onNativeDragDrop);
    vEvent.clipboard.clear();
    dragDropEvent = null;
    httpUrl = null;
}

My Problem is that When i am dragging and dropping an image from IE8, URL showing NULL(i.e httpUrl = NULL) but in case of Chrome an Firefox it is working fine.

I don't know how to solve.

So I want the solution to work on Internet Explorer8.

Aucun commentaire:

Enregistrer un commentaire