PDA

View Full Version : Adobe Air, AS3 and trace();



Ricardinho
March 5th, 2008, 05:17 PM
So ive just really got to grips with AS2 then AS3 kicks me right in the balls!!

Im trying out a Air app where you simply drag and drop a jpg onto the app and it loads the jpg.. its from a flv tut from gotoandlearn.com.

the problem im having is i want to drag and drop jpgs from a browser window and have it load. Its weird because the process works in the .swf format but when published in Air it cant pick up the Url/path anymore???

(desktop drag and drops work fine as it can find the path)

Heres the code:



import flash.desktop.NativeDragManager;
import flash.events.NativeDragEvent;
import flash.desktop.ClipboardFormats;

var imageLoader:Loader = new Loader();
dropBox.addChild(imageLoader);



this.addEventListener(NativeDragEvent.NATIVE_DRAG_ ENTER, onDragEnter);
this.addEventListener(NativeDragEvent.NATIVE_DRAG_ DROP, onDragDrop);

function onDragEnter(e:NativeDragEvent):void{
var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FOR MAT);

if(fa[0].extension=="jpg"){
NativeDragManager.acceptDragDrop(this);
}
}

function onDragDrop(e:NativeDragEvent):void{
var fa:Object = e.clipboard.getData(ClipboardFormats.FILE_LIST_FOR MAT);

imageLoader.load(new URLRequest(fa[0].url));
//trace(fa);
}





what do i need to do to alter:

imageLoader.load(new URLRequest(fa[0].url));

to make it get the correct path? or is this simply a security problem/issue?

Why does the .swf work but not the Air app?

And finally i tried to trace the issue but how can i trace when publishing in Air?

Any help would be great. Thanks!

Rezmason
March 5th, 2008, 06:08 PM
I'm looking for answers to pretty much the same questions, but I do know how you can trace() when you're using AIR. If you have the Flash debug player (http://www.adobe.com/support/flashplayer/downloads.html#fp9) installed, you can configure a file (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Book_Parts&file=logging_125_04.html) called "mm.cfg" to enable trace logging. Afterward, each time any trace() is called in the Flash authoring environment, in the debug player, or in an AIR app, the output will be appended to a log file in a certain location.


But yeah, what the heck do I have to do to load or save a file in AIR? Sheesh.

Ricardinho
March 6th, 2008, 04:16 AM
Bump

Scorpion_Blood
March 28th, 2008, 03:10 PM
there's a problem when you use the trace() in AIR, the only why to see the traces it's ctrl+shift+enter(build in debug mode) and not only ctrl+enter

ajcates
March 28th, 2008, 05:13 PM
For bigger projects, sometimes trace just doesn't do it, so I create a text field and output debug data to it. On my old no longer usable hardrive, I had written a samll cnsole program that I used to debug programs, because I never learned how to really work with flashes debugger.

amarghosh
March 29th, 2008, 12:52 AM
may be the link in my signature will help u. its a debugger class i wrote. download the files, include cdacBangalore.utils.Debug class in your AS file and call any of the three static methods Debug.write(), Debug.writeError(), Debug.writeWarning() instead of trace. it will display the message in debugger.swf and trace it in trace window also. make sure that debugger.swf is running in browser and not in a stand alone player. even after launching ur site u can do remote debugging. just keep debugger.swf in server and open it from client machine while your movie is running.

hope this helps someone