1
\$\begingroup\$

So I have an engine (air application) that basically (for now) is loading some windows on the screen/stage, and you can drag them around. And later on, I'll be able to add other objects onto the stage.

How would I export any kind of information (like co-ordinates or sizes of windows) out of my application to an external custom file. And then I would use that file to reload a previous project if I were to re-load the engine.

I'm working in AS3/Air and in FlashDevelop.

Thanks for the help and time. If anymore information is needed please let me know.

Cheers.

\$\endgroup\$
1
\$\begingroup\$

since you're creating the windows and have the drag / sizing information do you not already have the x,y, width, height information?

for saving files, AIR will allow you to do this without user prompting (what it sounds like your after) through the flash.filesystem. The AS3 should be something like the following (not tested)

import flash.filesystem.*;  
import flash.events.Event;  

private function saveFile():void{  
    var file:File = File.desktopDirectory; // change to suit your needs  
    file= file.resolvePath("example.txt");  
    var fileStream:FileStream = new FileStream();  
    fileStream.openAsync(file, FileMode.WRITE);  
    fileStream.writeUTFBytes("Saved content!!!"); // change this for the data you want   
    fileStream.addEventListener(Event.CLOSE, fileClosed);  
    fileStream.close();  
}

function fileClosed(event:Event):void {  
   trace("closed file event!");  
}        

Hope that helps ;-)

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.