Generate Actionscript 3 code with Eclipse Monkey (Flex Builder)

June 1, 2008 by Panel

Writing getters, setters, handler functions and even consts takes time. After working for a while I got feeling that this process can be automated. Lately I have discovered Eclipse plugin called Dash (thanks to eokyere). It contains Eclipse Monkey witch s a dynamic scripting tool. Scripts (written in Javascript) can be used to generate Actionscript code directly inside FlexBuilder.

Watch quick demo

Instalation

  1. Inside FlexBuilder to to Help-> Software Updates-> Find and Install
  2. Search new features to install
  3. Add New Remote Site (enter name and url (http://download.eclipse.org/technology/dash/update)
  4. Click finish to check for updates and install Eclipse Monkey
  5. Restart Flex Builder
  6. You should see Script menu
  7. File -> New -> Other… -> General -> Project
  8. Enter project name ex. Eclipse Monkey Scripts & click Finish
  9. Create script folder inside this project and copy scripts
  10. Now all scripts should be available in Scripts menu - if not select Eclipse Monkey Scripts project and press F5 (or right click on project -> refreash) to refresh it

Scripts

As you have seen on the video I have already created few scripts for Generate Event Handlers, Generate Properties and Generate Consts. I also have two scripts from Konstantin Kovalev blog.

Actionscript Code Generate Scripts (Eclipse Monkey)

Additional Resources

Usage Info

Eclipse Monkey help

Creating Scripts

Creating a new Eclipse Monkey script

Scripting Eclipse with the Monkey

Documentation

Eclipse Monkey/Javascript Editor doc

Eclipse Platform API Specification (org.eclipse.jface is important)

Javascript doc

Other

Script Exchange

Bug in addChild method

May 31, 2008 by Panel

Yesterday I have discovered that addChild method of DisplayObject is not working as expected. While adding new child to displayList it ignores override for width/height getters.

It can be very confusing. Imagine you have image gallery witch displays images in row. Now you wanna mask 3 of them to make only 3 of them visible at time and create some scroll. If you are using some advanced layout system (let’s say you wanna center your image gallery) natural step it to override get width/get height properties, so mask size will be returned instead.

Here is Code Sample