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

Compare with Current View Page History

« Previous Version 11 Next »

History

  • 1/11/2013 - MXML-based project can now be compiled into a working HTML/JS project
  • 2/10/2013 - Added HTTPService, LazyCollection, and a List class.
  • 3/01/2013 - Added Adobe Flash Builder integration.
  • 4/23/2013 - Updated to use FalconJX instead of FalconJS.
  • 6/27/2013 - Added the beginnings of MXML states and databinding.

Set Up

This is the setup for developers working with the source code. If you only want to use Flash Builder to play with the FlexJS framework, see: Using FlexJS with Adobe Flash Builder.

  1. Get Apache Flex 4.9 up and running. We don't really use any of its code, but getting it up and running makes sure you have the build tools and playerglobal.swc we need.
  2. Get the ASJS code from Apache Git via
    git clone https://git-wip-us.apache.org/repos/asf/flex-asjs asjs
    cd asjs
    git checkout develop
    
  3. In the frameworks/as folder, run ant. You may need a local.properties or a FLEX_HOME environment variable to build successfully. This should result in a frameworks/as/libs/FlexJSUI.swc
  4. Get the Falcon code from Apache Git at
    git clone https://git-wip-us.apache.org/repos/asf/flex-falcon.git falcon
    cd falcon
    git checkout develop
    
  5. Run ant to build Falcon.
  6. Change to compiler.jx folder and run ant to build FalconJX.

There are eclipse project files in the falcon repo. The run/debug configuration for building a FlexJS SWF in Eclipse needs the following settings (ApacheFlexJS is an overlaid Apache Flex 4.9 SDK):

Program Arguments:

+flexlib="/Users/aharui/Work/ApacheFlexJS/frameworks" -debug /Users/aharui/git/flex/master/asjs/examples/FlexJSTest_again/src/FlexJSTest_again.mxml -library-path+=/Users/aharui/git/flex/master/asjs/frameworks/as/libs/ -compiler.mxml.children-as-data

VM Arguments:

-Xmx384m -Dsun.io.useCanonCaches=false -Dflexcompiler="/Users/aharui/git/flex/master/falcon/compiler" -Dflexlib="/Users/aharui/Work/ApacheFlexJS/frameworks"

And the environment variables:
FLEX_HOME points to a Flex SDK and PLAYERGLOBAL_HOME are points to a playerglobal.swc

For cross-compiling with FalconJX the Program Arguments are:

+flexlib="/Users/aharui/Work/ApacheFlexJS/frameworks" -debug /Users/aharui/git/flex/master/asjs/examples/FlexJSTest_again/src/FlexJSTest_again.mxml -js-output-type=FLEXJS -compiler.mxml.children-as-data -closure-lib=/Applications/GoogleClosure/library -sdk-js-lib=/Users/aharui/git/flex/master/asjs/frameworks/js/FlexJS/src

The Demo

MXML->SWF
The latest demo is http://people.apache.org/~aharui/FlexJS/DataBindingTest. Run the bin-release/DataBindingTest.html and right-click and choose "View Source" to see the source. You should be able to compile DataBindingTest.mxml into a working SWF by using Falcon (and not the MXMLC compiler in Apache Flex 4.9). Find the Falcon mxmlc script in the Falcon folders under compiler/generated/dist/sdk/bin and run:

mxmlc -compiler.mxml.children-as-data -library-path+=<path to folder containing FlexJSUI.swc> DataBindingTest.mxml

You should be able to launch the SWF, see a simple application that allows you to choose a stock symbol and get information about it.

MXML->JS
Now you should be able to create an HTML/JS equivalent by running FalconJX. In compiler.jx/bin is its mxmlc script. Use the arguments below:

mxmlc -js-output-type=FLEXJS -compiler.mxml.children-as-data -closure-lib=/Applications/GoogleClosure/library -sdk-js-lib=/Users/aharui/git/flex/master/asjs/frameworks/js/FlexJS/src -library-path+=<path to folder containing FlexJSUI.swc> DataBindingTest.mxml

and the FalconJX compiler will generate an index.html file and a single minified .js file.

If you then open the HTML file in a browser (I've used FireFox, Chrome and Safari on Mac and FireFox, Chrome and IE8 and IE9 on Windows) you will again see the button and text and clicking on the button will change the text but hey! no Flash is involved. It is pure HTML/JS. Compare the SWF version and the HTML/JS version. They should look pretty similar. I don't know if we can make it exactly the same as it looks in Flash, but we should be able to get better visual match.

MXML->Cordova/PhoneGap

Once you have the HTML and JS file(s), you can copy these into the www folder in a Cordova/PhoneGap application and publish it and see it work on a phone or desktop emulator. A To Do item is to automate this process.

Discussion

As you can hopefully see, the first building blocks are now in place such that the ASJS framework and FalconJX compiler can create applications using familiar tools, components, and workflows. You can use Adobe Flash Builder or other Flex-capable IDE to quickly build or prototype an application on Flash using structured-programming techniques afforded by ActionScript, then convert it to a HTML/JS application that can run on browsers or mobile devices without Flash.

Next Steps

  • More components
  • More advanced and complete CSS handling for default values
  • More advanced Data-binding syntax support
  • No labels