FlexJS Frequently Asked Questions (FAQ)
What is FlexJS?
FlexJS is the next-generation Flex SDK that that has the goal of allowing applications developed in MXML and ActionScript to not only run in the Flash/AIR runtimes, but also to run natively in the browser without Flash, on mobile devices as a PhoneGap/Cordova application, and in embedded JS environments such as Chromium Embedded Framework. FlexJS has the potential to allow your MXML and ActionScript code to run in even more places than Flash currently does.
Is FlexJS Backward Compatible With the Flex SDK?
Unlike the Flex SDK, which tried to get you to use either the MX or Spark component set, FlexJS is being designed to support a wider variety of component sets. Most of the development effort so far has focused on the "Basic" set, which is not 100% compatible with the current Flex SDK. For the Basic component set, many implementation decisions will be decided by what will result in optimal JS output as well as what can be implemented in the short term in JS.
Work has started on trying to make a heavier, slower component set that more closely mimics the MX and/or Spark component set. It still won't be 100% backward compatible because the JS runtimes don't support things like weak references, but should be much more compatible. However, this is a huge undertaking. Volunteers are definitely need to help on this component set.
However, the goal is definitely to try to utilize as much existing MXML and ActionScript in existing applications as possible, and leverage the knowledge base and skill sets of experienced Flex developers and even leverage the tools such as Adobe Flash Builder. If you have an application consisting of 10,000 lines of MXML and 100,000 lines of ActionScript, instead of having to rewrite each and every line directly to JS or to some other JS framework, you should be able to use FlexJS and rewrite significantly fewer lines to get this code to run without Flash.
How much work will it be to switch from Flex to FlexJS?
A quick assessment of the how much work it will be to switch to FlexJS can be done by searching existing code for "import flash". Files that import classes from Flash packages are generally using APIs that will not be in versions of FlexJS. Note that importing flash classes in MXML files is not required so finding use of low-level Flash APIs in MXML files is not practical. Some Flash classes are events which may be supported by FlexJS.
One way to think about the migration to FlexJS is to ask whether you would have had to rewrite it anyway. For example, there is no support at this time for Remote Object. If possible, switching to JSON is recommended as it is supported in both AS and JS.
Does FlexJS Support E4X?
What level of Browser support is required?
The plan is to support IE9 and later, and relatively recent versions of FireFox and Chrome and probably even Safari. Mobile browsers will work as well, enabling your FlexJS web apps to be used virtually anywhere, even on IOS devices. Thus an HTML5-capable browser is not a requirement to use FlexJS. There may be different versions of the JS components that are HTML5-dependent that provide faster or smaller output if you can require HTML5 browsers for your target customers.
Can we use JS Frameworks like JQuery or Dojo?
As mentioned above, FlexJS intends to support a wider range of component sets. There is already a prototype of a few components that leverage JQueryUI. The Application class sets up JQuery and then the Button component wraps the JQuery Button. Thus it is possible to use MXML and AS to construct a JQuery application.
What about performance?
One unanswered concern at this time is about performance of the JS output. We won't know for sure until we get enough infrastructure working to run a large app, but the goal is for the Basic component set is for the JS code to be as low overhead as possible. If you were to migrate your app to JS either directly or via some other JS framework, you would most likely use some sort of object-oriented concepts in this app. When creating components for FlexJS we look at what those constructs might be and then translate them to AS classes thus keeping overhead lower than writing code that leverages Flash and then trying to translate it to JS. Thus, if there is a performance problem with the FlexJS output, it would likely have been the case even if you had used some other JS framework.
Can I use FlexJS to convert my Flex code to HTML/JS/CSS?
It is probably possible to create a tool that translates your MXML to HTML in some way so that you can run your application through the compiler, get HTML and JS and never go back to MXML and AS again. There will likely be some way to dump out the HTML from the app at runtime. But many UIs are too dynamic to be easily represented in HTML. Thus the goal of FlexJS is to provide for the use of MXML and ActionScript as the ongoing development language.
Why also output to SWF?
There is an advantage to using a more strict language like ActionScript in your development and why Flex was so successful at developing enterprise-grade applications. There are fewer ways to make small but highly-impactful mistakes in AS. Hopefully your large applications are written with some level of modularity. The language and compiler force you to be more careful at the integration points between those modules. And while some JS frameworks can do much of that as well, the fact that you can produce a version of your application that runs as a SWF in Flash gives you one more level of checking because the Flash ActionScript VM will perform runtime checking of your code. This is especially important in highly dynamic applications where modules are loaded on the fly and may be provided by third parties. There is not always a practical way to compile-time check that the integration points are fulfilling the contracts in other JS frameworks if you don't have all of the code in one place.
Also, if you can use Flash in the browser, you will likely save on the cost of testing your application in those browsers. You may also choose to use the Flash version in older browser so you can use an HTML5-dependent component set in other browsers.
Won't it take several years before FlexJS is ready?
The current Flex SDK represents many years of development. There is no way a volunteer-based effort can quickly reproduce a next-generation of all of that code. But under the hood, the new framework is designed to leverage incremental development. The most common APIs of the most popular UI controls will be developed first, then additional functionality will be added over time. How soon that happens depends on how many people get involved and contribute.
How can I get involved?
Participation in any form is encouraged and welcomed. To follow the development of FlexJS, please subscribe to the Apache Flex mailing list firstname.lastname@example.org. This is a high traffic list that covers development of the current Flex SDK as well, but we try to mark all FlexJS discussion with the subject "FlexJS".
Where do I get the source code?
The source code is in the "develop" branch at https://git-wip-us.apache.org/repos/asf/flex-asjs.