how to listen serial.print with flash ?


I begin with Arduino and I search to send varible value with arduino to Proxy (serial.print ??) and, after, read this value with Flash

(In my project, I send orders to Arduino with Flash and, sometimes the connection is refused by the proxy. I want to re-send order if the value in Arduino isn't good...)

If you have a little example ...? please !

You may need to re-phrase your post. Its not clear what you are asking.

Do you use an ethernet shield? Or serial communication?

flash is typically what is known as the program memory on the Arduino. Are you talking about the PC software?

If so, you can try and code your app to resend if it doesn't receive a response in a certain time. You will also have to make sure the Arduino can send a response with every request it receives.

Adobe Flash player, either standalone or as a browser plugin does not have access to the serial port.

Flash can access network connections, so you would need to run some sort of network to serial bridge server on the computer to which the Arduino was connected.

I've not personally tried it, but this link is supposed to be the software to do it that way


Alternatively, you could package your Flash program as Adobe AIR, and use an AIR Native Extension See


Also as noted on that forum, packagers like MDM Zinc may also have the functionality you want

Sorry, I m french and my english…

I use the serial communication. with serproxy for the link between Flash (the software!) and arduino.
The program is to run a engine

My problem : sometimes the connection is refused !
I’ve think to code my app to resend if it doesn’t receive a response (thanks pYro !) but I don’t know how to make that !!

In Arduino :

#include <Servo.h>

int demarre;
int pinI1=8;//define I1 interface
int pinI2=11;//define I2 interface 
int speedpinA=9;//enable motor A
int spead =60;//define the spead of motor

void setup()

void loop()
     if(Serial.available() >0)
    demarre =;
    if (demarre == 'E')
     analogWrite(speedpinA,spead);//input a simulation value to set the speed
      if (demarre == 'C')

In Flash :

import flash.display.Sprite;

var _socket:Socket;
var _proxyAddress:String = "";
var _proxyPort:uint = 5331;

_socket = new Socket();

function onClic1(pEvt:Event):void

    _socket.connect(_proxyAddress, _proxyPort);	
    var ENDOF_1:String = "E";	
	trace ("Droite");	
	_socket.writeUTFBytes(ENDOF_1);//send this string value to arduino

function onClic2(pEvt:Event):void

    _socket.connect(_proxyAddress, _proxyPort);	
    var ENDOF_2:String = "C";	
	trace ("Gauche");	
	_socket.writeUTFBytes(ENDOF_2);//send this string value to arduino

function onClicStop(pEvt:Event):void

    _socket.connect(_proxyAddress, _proxyPort);	
    var ENDOF_S:String = "S";	
	trace ("stop");	
	_socket.writeUTFBytes(ENDOF_S);//send this string value to arduino

btn1.addEventListener(MouseEvent.CLICK, onClic1);
btn2.addEventListener(MouseEvent.CLICK, onClic2);
btnStop.addEventListener(MouseEvent.CLICK, onClicStop);

in serproxy :

# Transform newlines coming from the serial port into nils
# if using Flash AS2 or AS1 : true
# if using Flash AS3 : false


# Idle time out in seconds


This does not seem to be an Arduino issue.

sometimes the connection is refused !

It sounds like the problem is with the serial proxy server

I suspect it is not closing the connection or you have the Arduino IDE also connecting to the same port.

I have never used that software so I can't be of more help

I've more informations ! I've make code to listen the problem and flash return this :

ArgumentError: Error #1063: Non-correspondance du nombre d'arguments sur Boutonallumermoteur1cs5_fla::MainTimeline/handleDisconnect(). 0 prévu(s), 1 détecté(s).

help me pleeeeeeeeeeeeeeease !!!

Your code is not very good

Why dont you just create a socket and leave it open, then just send the data whenever there is a click event

But with your current code I suspect the problem is you never close() the socket after each transfer

Looking at Adobe's docs on the socket class, flush() doesn't close, (And I would not expect it to close the connection)

BTW. The most interesting part of this is the serial proxy server

Which I actually located here

which takes the serial data and redirects it as a tcp port - which could be handy for other things, I wonder if it would be possible to upload a sketch to a Arduino with a wifi to serial module attached to the serial lines (albeit it won't do the hardware reset normally triggered duing the upload)

Thanks rogerClark !!!

I suspect the same think as you ! the close() ! but I have 2 problems : - I m a beginner in AS3 , I true to add the close function but I can't do ..... :blush: - English isn't my language and I understand half of the advice on the english forums !!

Please, can you write me a close function because my : _socket.close(); don't work !

I doubt that socket.close() is not working, its probably a bug in your code.

BTW. Best practice is not put your code on the timeline

Make a class for your main flash document and put the code inside the class

BTW. If you are using a PC, download FlashDevelop it will make your flash coding easier