This is my new open source project…

Flex TRAMP is a testing Runtime Actionscript Mini Parser,..

which means it allows you to interact with your running flex, and

  • create variables,
  • assign objects,
  • update attributes,
  • call methods
  • and basically interact with your flex app.

Why?

Me and some colleagues are currently working on a flex app that takes a while to build. It’s very frustrating to do a build, then see that some variable, or object is initialised with the wrong value, and have to rebuild again..

I’m used to working with FIrebug – if something goes wrong with my js, I can modify it on the fly, and try again.

Take this example: We’ve got a part of our app that prints some info out. To get to it, you have to enter lots of registration info, and perform lots of tasks.

With FlexTRAMP, I can fire up the app, and in the command line window that appears when I click the FlexTRAMP button, I can create and initialise all of the objects I need, and call the print method, again, and again and again.. no need to go through the whole registration process. Lots of time saved, I’m more productive, and therefore happier :)

Another example – only just today – I did a few changes and made a build. I found that the currentState of one of my component’s was wrong.. This meant I had to go back and rebuild again… however, using FlexTRAMP, I could still set the state, update a few vars, and one method call later, debug a transition I had, which I found needed a slight tweak.

So you see, I didn’t end up doing a build and achieving nothing.

For anyone used to Firebug, or Microsoft’s command line processors, you will know the use of this approach. It’s not a replacement for unit tests, but a very useful tool for when you have to get hacky with some defects, or trail blazing some code.

But I thought Actionscript doesnt have eval?

It doesn’t, and while some people are going to great lengths (and using great skill) to get a genuine eval in actionscript (such as compiling the bytcode and loading it back in through a swf), we’re not doing that.

We’re doing something much more simple, but just as effective for the purposes we have.

Who’s making it, what license?

I’m making FlexTramp, with some colleauges from Adobe Consulting – we are:

  • George Cook (me),
  • Ignacio Martin,
  • Mike Herron,
  • Satinder Ubhis.

The project is open source and will be hosted on google shortly. It will be released under the wftpl license.

What state is it in?

Currently there’s a spike I knocked up, which has some functionality:

  • variable assignment,
  • Object creation,
  • method invocation,
  • basic method info,
  • real basic operators, concatination and boolean expressions,
  • can add existing variables from your application!
  • access of static methods,

There are some limitations

  • only one type of operator (+ – * / ) per expression
  • not much nested anything (e.g (), []).. Parser is very ropey with brackets (only one set of brackets allowed per expression
  • no iteration (do, while,etc)
  • no functions.
  • only public variables/methods are accessible.. this will probably always be the case..
  • doing things like a0.length, or object.method().property, or object.method().method() is not supported yet..

Ugly, ugly parsing code!!

The parser I wrote is so utterly horrible (it’s just a quick proof of concept that mushroomed one afternoon) that I wont let anyone see the code at the mo!! it’s also the same reason tha there are so many limitations. Ignacio is working on a much nicer parser this week, and once we have implemented that, along with some of Sat and Mike’s stuff – we’ll be releasing the code to all and sundry.

We have lots of ideas for the future of this project, and our aim is to make something that will let you hack around, and get dirty with your code – basically some dirty little scutter of a parser, that allows you to get nasty, while still having some chic.

Think : ” the lady is a tramp”, and you’ll be catching our drift.

More real soon, I promise.

and I couldn’t help myself a kind of basic version is here:

Let’s try some code:

  1. a = " hello world!"
  2. myApp = mx.core.Application.application
  3. myButton = new mx.controls.Button()
  4. myApp.addChild( myButton )
  5. myButton.label = " Hello from TRAMP "
  6. myButton.width = 200
  7. myButton.height = 100
  8. mx.controls.Alert.show(myButton.label,"now you can play with your flex app in runtime :-)")
    • if you want to use that code, copy it into a text editor first, and remove the hash symbols that this blog puts at the start of each line (soz)

extra comands are “cls” to clear the output and delete VARNAME, to remove a variable.. e.g. delete myButton.

Note you can also enter multiline commands, so you can copy your fave snippets to a browser for later use.. double clicking on an element in the tree, will put a reference to it in your code window. BEWARE the tree (and the parser, for that matter) are quite ropey at the mo!

Example

Example of FlexTramp – it’s really early, so dont’ expect too much!+

I’ve been using this the last couple of days to debug a LCDS app with cairngorm. It’s great fun creating the cairngorm events and tweaking them and dispatching them over and over again, without having to rebuild.

More soon!