AIR: <img> will display drag-n-drop image, Loaders no ?

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

I'm basically putting together an AIR version of an existing application I wrote awhile ago.

So far I've got the AIR application accepting images that have been drag-n-dropped on the phone background and displaying/positioning them on the screen.

I can't seem to get my head around getting the image that has been dropped into the application into a BitmapData object so I can crop/etc it and save it to a new file though. It seems like a security sandbox thing, but it's been soo long since I've done anything with Flash, let alone AIR, that I really don't know.

Here's the function I'm using to display the dropped image
Code: [ Select ]
    function dropHandler(event)
    {
        var str = event.dataTransfer.getData("text/plain");
        var elm = document.getElementById('iphone-wallpaper');
        air.trace(elm.style.backgroundImage);
       
        elm.src = str;
    }
  1.     function dropHandler(event)
  2.     {
  3.         var str = event.dataTransfer.getData("text/plain");
  4.         var elm = document.getElementById('iphone-wallpaper');
  5.         air.trace(elm.style.backgroundImage);
  6.        
  7.         elm.src = str;
  8.     }


Here's what I've tried for loading the BitmapData
Code: [ Select ]
var loader = new air.Loader();
// event handler definitions
loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, completeHandler);
loader.contentLoaderInfo.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler);
loader.load(new air.URLRequest(document.getElementById('iphone-wallpaper').src));
  1. var loader = new air.Loader();
  2. // event handler definitions
  3. loader.contentLoaderInfo.addEventListener(air.Event.COMPLETE, completeHandler);
  4. loader.contentLoaderInfo.addEventListener(air.IOErrorEvent.IO_ERROR, ioErrorHandler);
  5. loader.load(new air.URLRequest(document.getElementById('iphone-wallpaper').src));


Here's the error message I get for a local file
Code: [ Select ]
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035: URL Not Found. URL: file:///home/me/Desktop/1024-768-cat-wallpapers-11.jpg
" errorID=2035]
 
  1. [IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2035: URL Not Found. URL: file:///home/me/Desktop/1024-768-cat-wallpapers-11.jpg
  2. " errorID=2035]
  3.  


Here's the message for a file dragged from my browser
Code: [ Select ]
An ActionScript error has occurred:
TypeError: Value  does not allow function calls.
  1. An ActionScript error has occurred:
  2. TypeError: Value  does not allow function calls.


Any information is welcome. :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

Post Information

  • Total Posts in this topic: 1 post
  • Users browsing this forum: No registered users and 12 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.