About instance metadata in FP 11.6+

To this day, as it seems, the fastest way to load a bunch of zipped assets in FP or AIR app is to load SWF file. This way does not come without problems, however. One of them is that you can’t really unload classes and associated data. E.g. unloadAndStop docs state:

Any visual assets that were loaded with the SWF are unloaded and removed from memory. ActionScript class definitions in the loaded SWF remain in memory, and code in the same application domain as the loaded SWF can access instances of those classes and create new instances.

In other words, you can’t even give your symbol a class name if you are planning to unload it from memory at some point – you have to place symbol instances on the timeline and then use getChildAt to access them as raw DisplayObject-s. To make this situation somewhat better, 11.6 runtime introduced metaData property, so we could add custom data to our symbol instance without creating a class for it.

The catch is that until Flash CC we had zero tooling support for it, and in Flash CC setting instance methadata is pain in the arse. They do not give you any kind of UI to edit the data; instead, they expose these new JSFL APIs. On top of that, setPublishPersistentData call silently fails if you used array data types with setPersistentData (as if set of data types supported by setPersistentData was not limited enough already).

To sum up: if you are going to use this feature, you will have to create your own tools. One way to do that not involving struggling with Flash CC would be to use the library like AS3SWF. I have added PlaceObject4 tag support, and – yes – it does support arbitrary data. Remember that you need SWF version 19 to target FP 11.6 APIs.


Ask a Question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

Old stuff

July 2013
« Jun   Aug »

Oh, btw…


%d bloggers like this: