Arduino Flash communication AS3 – As3Glue bundle
I’ve created a Flash monitor application with As3Glue to make it easier to start with Flash Arduino communication.
Glue is an ActionScript 3.0 library that enables communication between Flash and Arduino boards with Firmata. Since Flash cannot interface the serial port directly we’ll use Serialproxy in between. Serialproxy converts incoming serial data the XMLsocket data.
The monitor is useful to check if all the connections are working good. You can monitor directly all the sensors and actuators connected to your Arduino board.
The example code file is a start point to program your own things controlled by Arduino.
Included files :
- AS3Glue files ( .net.eriksjodin.arduino )
- Tinkerproxy osx ( renamed to serproxy )
- Serialproxy windows ( renamed to serproxy )
- as3glue_standalone_monitor.fla
- as3glue_program-example.fla
The Firmata library is included with Arduino itself. Make sure you use Arduino 018, because the Firmata library included in version 017 is not stable.
Update (12-05-10, v1.3): I’ve updated the code for the support of two servo motors (pin 9 and pin 10).
Download the zip-file : arduino_as3glue_bundle_v1.4

Art&Technology related bookmarks
Hi Kasper,
I just discovered this little tool you made. This is great stuff! I will use it with my students to troubleshoot their projects. Thanks for making it available to the community.
Cheers!
By the way, you can also bypass security settings on an swf file by going to this address and authorizing the file, its parent folder or a whole drive:
http://www.macromedia.com/support/documentation/en/flashplayer/help/settings_manager04.html
I realized by watching your video that the same result could be achieved by publishing the .fla as a projector. I just never thought of doing that… Thanks again.
Hi Jean-Phillippe,
Thanks for the remarks and the Serialproxy 0.1.4 version.
The ‘advanced settings’ wouldn’t open anymore with right-click on my mac, so I thought it wasn’t supported anymore. Also because I was reading that Flash 9 and beyond have more restricted security settings and that you’ll need a ’socket policy file server’.
See : http://bit.ly/as3glue-examples-cs247_securityreadme
Another disadvantage with the security settings preferences is that you’ll need an internet connection to change them.
Hi Kasper, thanks for the amazing video tutorial and code. It has been really helpful.
I wonder whether this code can be used with the USB Host shield from circuits@home (www.circuitsathome.com)? I’m trying to use a playstation3 sixaxis controller for its accelerometer and gyro inputs but don’t seem to be having much luck. I’m guessing maybe because the hostshield has its own custom library, but when I follow your tutorial the standalone montior shows successfully connected but the graph stays more or less static and I don’t seem to be able to receive any data from the controller. Is there any way to use as3glue in this way? Or is there something I’m missing?
Many thanks,
David
Hi David,
I think its will be difficult since you don’t work with the normal I/O pins from the Arduino. Of course you can send serial data ( with serial.print ) to Flash. I have a AS3 script that listens to normal serial data send by the Arduino. Didn’t have time yet to publish it here. Send me a mail and I will reply it to you.
I’ve put the AS3 script with explanation online :
http://www.kasperkamperman.com/blog/arduino-flash-communication-as3-messenger/
Hello,
Great tool! But I was wondering how to control a servo with Glue. Using a PWM port makes the servo behave very strange and unpredictable so I was wondering if it’s possible to use the servo library from Arduino. Or maybe there is another way to do it :)
Many thanks,
Jim
Hi Jim,
I think that standardFirmata has servo support. As3glue supports 2 servo motors.
This you have to put in the ‘onReceiveFirmware function’ :
arduino.setupServo(pin,angle): Initialize servo timer routines on a pin. Pin must be 9 or 10 in the current implementation.
between 0 and 180.
From the timerEvent function you can use :
arduino.writeAnalogPin(pin, angle): Write a servo angle (in degrees) to an output pin. value has to be a number between 0 and 180. Pin must have been initialized with setupServo() before.
For more info see the As3Glue reference :
http://protolab.pbworks.com/As3glueReference
Let me know if it works, maybe I can modify my example files for servo support.
I managed to get it to work, thanks! I imported the ArduinoWithServo file which worked great combined with the code you posted.
Great tutorial. I am using Arduino with 3 Potentiometers to talk to Flash for an interactive media project for my thesis. I was thinking of trying out ArduinoProcessingFlash with processing as the middleware from Kan Yan Li, http://a.parsons.edu/~lik43/doc/?p=859.
Do you know any advantage to this? I don’t think I need to use Processing really except for displaying a video onscreen as Arduino’s pot. inputs trigger/respond to events in Flash/AS3.
Is it more robust to just cut out Processing (the middleware)?
/Vinny
Hi Vincent,
I couldn’t open that website, but I think its using Processing for the serial to Xmlsocket conversion. In my version Serialproxy is used for that.
You need the middleware since Flash cannot communicate directly with the serialport.
Another option as middleware could be funnel.cc.
I prefer Serialproxy for most of my projects and teaching, since its the most basic option.
Kasper
Hiya,
thanks for the reply.
Yes that site was in downtime last I checked. But I figured out what I wanted to make/do. So I went with Tinkerproxy and as3glue as you recommeneded.
Having quite a lot of fun with making the Flash App and dynamic filters from pixel bender.
Best regards
V
Hello kasperkamperman, where can I get “as3glue_standalone_monitor.fla” and “as3glue_program-example.fla” ? Thanks for all :)
They are in the zip-file.
Hi kasperkamperman.
I wired a push button switch.
I’m monitoring each of the pins from 2 – 13 as digitalIn.
The monitor displays two inputs at the same time when my push button is connected to one pin only.
For example: Push button sends the signal to pin 8 and the monitor displays that 7 and 8 are being pressed.
¿Why is this?
I already tried this with two different Arduinos.
I was using tty instead of cu on my serial port. I don’t know what’s the difference but apparently it was that what caused the false positives.
Although I still get some when the push button bounces.
Since there is nothing connected to pin 7 (no ground, no 5V) it can change due electrical noise. If you watch the analog inputs you see the same effect. Change one input, and they probably change all.
The solution is to wire the unused pins to ground. However, that would be just for the looks. If you didn’t connect something to pin 7, you don’t want to listen to it in Flash. It doesn’t matter that it changes, if you don’t use the values of that pin.
True.
When Flash is listening to pins 7 and 8 with two different buttons there is no noise.