You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

A FlexJS SWC is intended to be an compressed archive of not only pre-compiled ActionScript code and related assets, but also for a collection of JavaScript files that mirror the ActionScript classes in the SWC.  That way, a SWC can be deployed and used in a project without having to also copy around a pile of JS files.

The recommended order of operation for creating a SWC is:

1) Cross-compile the AS to JS

2) (Optional) Create an Externs SWC.  An Externs SWC is needed so that APIs only available in the JS runtime are available to SWCs that depend on the SWC you are creating.

3) Compile the AS into a SWC and use include-files to include the cross-compiled JS output.

 

There doesn't appear to be a way to easily do the three steps from a single Flex Library project in Adobe Flash Builder, unless you also add an Ant Builder to the project.  Some folks use two Flex Library projects instead.

 

The FlexJS framework uses Ant scripts to create the SWC.  In each folder in frameworks/projects, you should find:

a) build.xml - the Ant script

b) src/main/resources/compile-asjs-config.xml  - Settings used to cross-compile AS to JS and also to create the Externs SWC

c) src/main/resources/compile-config.xml - Settings used to compile the AS to SWF byte code and package the cross-compiled JS output files into the SWC.

 

The Ant script performs the 3 steps of the order of operation, but also copies the JS files to frameworks/js/FlexJS/libs.  When an application is being compiled and JS files are finally need to be linked into the cross-compiled output, the FalconJX compiler looks there before it looks in the SWC for a JS file that matches an AS class.  This allows developers to monkey-patch and quickly try changes to the JS without having to re-build the entire SWC.

When compiling in step 1 and 2, the COMPILE::AS3 conditional compilation flag is set to false and COMPILE:JS is true.  Only on the last step 3 is COMPILE::AS3 set to true and COMPILE::JS set to false.

 

  • No labels