Java, Flash and BeanShell: winning team!

I’ve been working on a control system for an exhibition lately, designing and writing software for an interactive movie theater.

The audience will use hardware buttons (interfaced via an Ethernet-based module) to vote and decide which short film to play next, based on an interactive display of choices and votes.

From the kind of project and the team’s organisation, I felt early on that the specs were going to evolve a lot during the project (read: chaotic team, but mostly in a nice sense). Flexibility of the software is a big requirement here.

That’s where BeanShell comes in: being able to glue robust java components with a few lines of script to define the interactions between the various mechanical and multimedia components has been a big help.

I’ve been thinking a lot about how to best combine compiled and interpreted code lately, and this is it! First you build your java components, quickly play with them with small scripts to get the interfaces right, and finally you write interpreted stuff like:

// display choices and vote
flashDisplay.showScreen("screen-1 selection=12");
filmName =;
// prepare to play film
// play film and wait for end;
. . .

This is the kind of code that you can even show to your customers to discuss the details, but all the critical machinery is safely defined in java code.

The coin dropped when, during a demo, I was able to design and show a new transition (by editing one file while the system was running) on the big screen while people were arguing about how best to move from film to vote phases. They saw it, they like it, case closed!

Scripting is here to stay, and I’m very happy with this combination. There’s much more to BeanShell than what the above examples show: event handlers, interfaces, typeless or strict programming, it is very flexible.

For the visuals we use Flash – I’m fortunate to be in touch with Pierre Rossel who’s got the right mix of programming and artistic skills to build a Flash-based “intelligent slave display” which is under complete control of the java/BeanShell code and puts a nice face on it all.

This project has really been an eye-opener for me – although not very original, this combination of tools has allowed us to answer every request easily. You want it beautiful? Put it in the Flash module. Complex and robust? Create a new java component. Quick and easy? Ask BeanShell.

It’s hard to go back to less exciting projects after this, but so is life…

6 Responses to Java, Flash and BeanShell: winning team!

  1. Forgive my ignorance, but how is Java (or ultimately Beanshell) able to drive a flash presentation?

  2. In this system, the Flash “display slave” opens a socket to the java system, which sends simple textual commands to it. It was done this way because it seemed easier for Flash to open the socket connection than to accept it.

    ActionScript code then picks up the commands and triggers the appropriate animation components.

  3. Randito says:

    There are tons of options for integrating Flash apps with Java servers.

    Flash can open sockets and receive incoming Xml/text. (Xml Socket servers)

    Flash can make Xml-Rpc calls to a server.

    Flash can make native calls to a Java backend. (Flash remoting).

    And now, Java servers can host Flash apps that are designed/configured via Xml.

  4. e vigilar says:

    I have read your posting that you are able to make Java apps talk to Flash and vice versa.
    I am thinking of working on a project which uses Flash for the interface and Java (not Java Script) for the commands to the back end.
    I would like to confirm if it is through Action Script that the Flash communicates with Java applications.
    I would also like to know what are the essentials if I need Flash to communicate with a database application.
    Do you know any references on this.
    Thanks! More Power.

  5. Yes, ActionScript is used to implement the socket communications with the Java modules.

    Once you get a socket connection you can do whatever suits your project, but, compared to higher level forms of communications, using plain sockets forces you to invent your own control protocol.

  6. Samuel Lee says:

    Dear Sir,

    I am a beginner in Java and Flash. Could you give me a “hello world” sample using openAMF from java project into flash presentation? This sample will help me to start and I’m really appreciate for the help. Please send it to Thank you.

    Best Regards,
    Samuel Lee

%d bloggers like this: