Skip to main content
Known Participant
August 19, 2011
Answered

Saving a MC to a PNG file - Not to the Camera Roll

  • August 19, 2011
  • 1 reply
  • 2291 views

Hello

I have a MC called Picture_mc and its of the size of all the screen, I need to save this to iOS file system in order to load it when my app start again. I don´t need to save it to camera roll because is har to load later from there. I Think is something like Shared objects?

Anybody know how to do this?

Thank you

This topic has been closed for replies.
Correct answer Colin Holgate

That example code page I showed is AS3, in a Package. I wrote before about how you can get that into timeline code, but it's worth you trying to understand the code, then you can copy the parts that you need into your own code.

As for saving a picture, you can JPEG compress it, and save the btyearray you get in a SharedObject. At sensible quality settings you should be able to get it below 100K.


I don't know if AIR for iOS has the 100k limit.

The JPEGEncoder is part of ascorelib, which you can get by click the downloads button on the right side of this page:

https://github.com/mikechambers/as3corelib

1 reply

Inspiring
August 19, 2011

you have to save it in the applicationStorageDirectory.

to understand the basic principle go first here :

http://www.thekuroko.com/2007/05/articles/news/reading-a-file-with-actionscript-3/


to adapt it to save png file : go there to find inspiration :

http://www.switchonthecode.com/tutorials/adobe-air-and-flex-saving-serialized-objects-to-file


enjoy
Participating Frequently
August 19, 2011

Do you want to specifically save it as a PNG file (for use by other apps, perhaps) or just as something you can load in your app in the future?

If the former, you have to use a PNG encoder to create a byte array containing the PNG formatted data.

If the latter, you can use shared object or the File API. In this instance, you want to save the BitmapData object, not a Bitmap object. (In general, objects that inherit from the DisplayObject class, like Bitmap and MovieClip, cannot be easily saved and loaded -- serialized is the jargon for this.) Using a shared object is the simplest way, I expect.

Known Participant
August 19, 2011

Thanks for both answers

I need to save the PNG (or may be JPG) to load it in my App anytime ... anybody has exmples of code? (save/load)?

Thank you