*****FOR Action script 3 programmer*******
Posted: 02 August 2013 03:33 PM   [ Ignore ]
Rank
Joined  2009-08-07
Total Posts:  69
New Member

Helloo
i build my multtouch application so i want to know how can save text into .txt in my computer or save stage as image now i use TUIO event so when use FileReference class not work with me so i want to create multitouch file browser to can save anythings sooo anyperson can help me how can save by TUIOEvent any class for this or what i do??

Profile
 
 
Posted: 04 August 2013 06:48 PM   [ Ignore ]   [ # 1 ]
Avatar
RankRank
Joined  2009-05-06
Total Posts:  158
Member

To save text:

// create file object (in this example on the desktop)
var file:File File.desktopDirectory.resolvePath("myfile.txt");
// create a file stream for writing to file
var stream:FileStream = new FileStream();
// open the stream with the file
stream.open(fileFileMode.WRITE);
// write text using writeUTFBytes
stream.writeUTFBytes("Text you want to save");
// close the stream
stream.close();

To save the stage to an image use the following. This requires the latest version of Adobe AIR as it uses the built in PNG encoder.

// create a bitmapdata object
var bmd:BitmapData = new BitmapData(stage.stageWidthstage.stageHeight);
// draw the stage to the bitmap data
bmd.draw(stage);
// create a bytearray for storing encoded bitmap data
var ba:ByteArray = new ByteArray();
// encode the bitmap to PNG using AIR's PNG encoder
bmd.encode(bmd.rect, new PNGEncoderOptions(), ba);

// create file object
var file:File File.desktopDirectory.resolvePath("image.png");
// create a file stream for writing to file
var stream:FileStream = new FileStream();
// open the stream with the file
stream.open(fileFileMode.WRITE);
// write byetarray using writeBytes
stream.writeBytes(ba);
// close the stream
stream.close();

 Signature 

web: http://www.nemenvisual.com
blog: http://www.purplesquirrels.com.au

Profile
 
 
Posted: 05 August 2013 07:03 AM   [ Ignore ]   [ # 2 ]
Rank
Joined  2009-08-07
Total Posts:  69
New Member

thank you so much but i ask you can use this code with flash5.5 and swf i think filestream with air only :(

Profile
 
 
Posted: 05 August 2013 07:18 AM   [ Ignore ]   [ # 3 ]
Rank
Joined  2009-08-07
Total Posts:  69
New Member

i saw your application in this link use save location window or open like in pic how can used in TouchEvent or TUIOEvent http://nuigroup.com/forums/viewthread/12823/

Image Attachments
to.png
Profile