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

Compare with Current View Page History

« Previous Version 4 Current »

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 steps for creating a SWC is:

1) Create a Flex Library project

2) (Optionally) Create a "JS" Flex Library project to produce a "JS" SWC.  A "JS" SWC is needed if APIs only available in the JS runtime are available to other SWCs and any runtime-specific code you are creating.

When you edit and save changes to AS files in the project, the cross-compiler will generate the JS files and include them in the SWC.  If you have created a "JS" Flex Library project, the compiler will also update the "JS" SWC.

Most, if not all, of the FlexJS framework SWCs use two Flex Library projects to produce a SWC with Flash-specific APIs and another with JS-specific APIs.  The APIs in common are the ones the application developer can use to write code that will work on both runtimes.

 

The FlexJS framework uses Ant scripts to create the SWCs.   For each SWC, like Core, there should be:

a) build.xml - the Ant script (in frameworks/projects/Core, and another one in frameworks/js/FlexJS/projects/Core)

b) (in frameworks/js/FlexJS/projects/Core) src/main/resources/compile-js-config.xml  - Settings used to cross-compile AS to JS for the "JS" SWC

c) (in frameworks/projects/Core) src/main/resources/compile-as-config.xml - Settings used to compile the AS to SWF byte code and include the cross-compiled JS  from the "JS" SWC.

 

When compiling the Flash-specific SWC, the COMPILE::SWF conditional compilation flag is set to false and COMPILE:JS is true.  When cross-compiling AS to JS,  COMPILE::SWF set to true and COMPILE::JS set to false.

 

  • No labels