Azamath
Azamath

Reputation: 73

ActionScript3 - Saving objects created when application is running

I made an editor that allows to create some custom space ships for game I'm making. This editor is meant for the player and his ships are saved in SharedObject without a problem.

What i would like to do is to use the editor to create some ships for enemies and use them later when designing levels.

I was thinking about writing the Ship object to ByteArray and than tracing them so i can copy and paste them to code and read them back to object but this does not seem to work since what i get from tracing a ByteArray is only class name and few undefined symbols that i can't even paste here.

Upvotes: 1

Views: 96

Answers (1)

Andrey Popov
Andrey Popov

Reputation: 7510

The standard trace panel in flash is text based, therefore no bytes can be output properly (ByteArray).

I'm not pretty sure what are the types of objects you need to store, but you can do two things:

  • Save ByteArray to UTF8 external file; then read it back to ByteArray, and you're on the road again
  • if you need to trace them out, Base64 encode them (simple but powerful class here: https://gist.github.com/burakkirkil/4051420)

Upvotes: 1

Related Questions