Hacking the Flex SDK

The Flex SDK is finally fully open-source. So I thought I’d have a little fun and implement my own Binding classes to be used when using the [Bindable] metadata tag in an ActionScript 3 project.

The first thing I did of course was to checkout the Flex SDK from subversion. They’ve got instructions on doing all that in their wiki. The wiki also has some great instructions for downloading and installing ANT and the other things you’ll need to build the SDK. Look further down on the previously linked to page in the section “Building and testing.”

Once I had the project checked out I downloaded ANT per the Mac-specific instructions on the wiki. I the ran `source setup.sh` and then `ant -q main` just like they said and voila! I had built my own SDK. Of course, it was basically the same as the one already installed with Flex Builder.

I then started digging into the code and found in the sdk/modules/compiler/src/java/flex2/compiler/as3/binding/BindableProperty.vm template file that is used for the auto-generated binding code. I took out some of the imports, changed the [Bindable(event=”propertyChange”)] on line 62 to [Bindable(event=”${entry.propertyName}Change”)], and changed every place it had dispatchEvent(PropertyCha…. to dispatchEvent(new Event(“${entry.propertyName}Change”). This will allow my binding class that just looks for {propertyName}”Change” event for binding instead of using the expensive describeType function.

Next, I compiled the whole SDK and had issues, because the Flex framework needs to use the old binding. SO DON’T DO THAT. After backtracking and fixing things up I changed to the sdk/modules/compiler/ directory and THEN ran `ant -q main`. Now my mxmlc will use the new binding template but the old framework SWCs weren’t compiled wrong with it.

To check out the new generated classes compile your project using `mxmlc Main.as -keep`. That creates a folder called “generated” that has all those classes including your new bindable changes in it. Now in Flex Builder, you can add a your new SDK and compile your own projects. Haven’t had time to actually test this out yet and I’ve gotta run, but let me know if you get it working.

4 Responses to “Hacking the Flex SDK”

  1. Campus Vitals Says:

    Did you have any luck testing this out? What were the results?

  2. Jacob Wright Says:

    I was able to use my own binding class. Though, they’re getting rid of the .vm templates as they work on making performance better. I’m not usually poking through Java so it won’t be quite as easy to hack that as it was the templates.

  3. Tonté Pouncil Says:

    I was able to use my own builds based on the information on this site and the wiki.

    Thanks!

  4. Gallant Says:

    I didn’t see the full instructions on wiki?