Changing the properties of ActionScript objects in your iOS native code

We continue with our Translating between ActionScript and Objective-C series by adding a couple of mirror functions for reading and writing properties of ActionScript objects in your native Objective-C code.

What was covered so far?

What will this part cover?

The AIR C API strives to make most of what you can do in ActionScript possible to replicate in C. For example, if you have an object of type Date, named date and wanted to set its day property, you can do that. Only instead of the ActionScript one-liner

you need to write a few more lines and to a few checks to achieve the same in C. This is what the next function helps you with: set an arbitrary property of an arbitrary object, so long as you have a pointer to the object and know the property name.

Note that both the object whose property you are changing and the value you are changing to need to be FREObjects.

The call that does the actual job here is AIR C API’s FRESetObjectProperty.

The implementation

Result

This is how you use setFREObjectProperty in your Objective-C code:

What’s next?

Info: For a comprehensive data conversion guide and how to make it into a library download our eBook “iOS vs. ActionScript Data Types Guide”.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">