Using the New Inline Metadata in ASC2
UPDATE: There are ASC2 changes to the
[Inline] feature since preview 3 (Oct 8th)
There are many changes coming to tooling around ActionScript. One of the latest changes is something you can find in the labs.adobe.com release of Flash Builder 4.7. It’s the new ActionScript compiler, aka ASC2. Thibault does a great introduction blog post on the new compiler.
ASC2 has a lot going on, from better compiler times to supporting the new ActionScript worker API. The ASC2 is in beta and will continue to be improved over time. The feature I wanted to highlight in this post was the new metadata tag
[Inline]. At first I thought this would be a great way to speed up a lot of code, but it depends on the content and has some restrictions.
Lee Brimelow does a great job in this video showing how to get it working in Flash Builder 4.7. The video also demonstrates how the
[Inline] tag works.
To use the new metadata
[Inline] tag you need need to tell the ASC2 compiler to using inlining with a
-inline compiler argument. Here is a quick look at some of those requirements for the
[Inline] tag to work:
- The function is final, static or the containing scope is file or package Compiler Error Message:
The function myFunction could not be inlined, as only functions marked as final, static or global functions can be inlined.
- The function does not contain any activations
- The function does not contain any try or with statements
- The function does not contain any function closures
- Changed in preview 3 if using [Inline] not limited to 50 expressions.
The function body contains less than 50 expressions Compiler Error Message:
The function myFunction could not be inlined, as it contains 51 expressions. No more than 50 expressions can be in the function body.
I went through and tried the requirements listed above in Flash Builder 4.7 and ASC2 to get the compiler error messages above. Not all scenarios had compiler error messages, so you’ll want to double check your code to see if the inline is really working, Lee shows a way to do it with a decompiler in his video.
If you do start using ASC2 and find some differences with your application versus compiling with mxmlc you’ll want to check out the backward compability list here – http://helpx.adobe.com/flash-builder/actionscript-compiler-backward-compatibility.html