SerProxy+flash issues

I am having a weird problem. I am using SerProxy to send socket data from flash to arduino, and use the data to change the blinking interval for an LED in arduino.

all works fine when the serial monitor window is open, however, connection closes after a few seconds automatically (which seems to be a kown issue to alot of people, and everyone recommended that the IDE and serial monitor should be closed to avoid this).

if I close the serial monitor window, connection does not drop anymore, but arduino does not read my messages, it's like it does not recognize that there is any serial data at all.

here's the Arduino Code:

int  incomingByte = 1000;
int ledPin = 13;                 // LED connected to digital pin 13

void setup() {
  pinMode(ledPin, OUTPUT);   

void loop () {
   if (Serial.available() > 0) {            
      incomingByte =;
      incomingByte *= 10;
      // if I uncomment those lines and open the serial monitor window, 
      // the value is received alright, but connection closes automatically in a few seconds
      //Serial.println(incomingByte, DEC);
      //Serial.print(0, BYTE);
   digitalWrite(ledPin, HIGH);
   digitalWrite(ledPin, LOW); 

and here's my AS code:

import flash.utils.Timer;

var isDown:Boolean = false
var connectTimer:Timer;

// connects to arduino board
var arduino:SerialPort = new SerialPort();
arduino.addEventListener(DataEvent.DATA, onArduinoData );
arduino.addEventListener(Event.CONNECT, onConnect );
arduino.connect( "", 5331 );

function onConnect(e:Event):void
      trace("DATA CONNECTED")
      connectTimer = new Timer(2000);
      connectTimer.addEventListener(TimerEvent.TIMER, onConnectTimer);


function onConnectTimer(event:TimerEvent):void
      trace("now send data")
      connectTimer.removeEventListener(TimerEvent.TIMER, onConnectTimer);
      connectTimer = null;

      stage.addEventListener(MouseEvent.MOUSE_DOWN , onDown , false , 0 , true );
      stage.addEventListener(MouseEvent.MOUSE_UP , onUp , false , 0 , true );

function onDown(e:MouseEvent):void
      isDown = true;
function onUp(e:MouseEvent):void
      isDown = false;

function onTimer(e:TimerEvent):void
      if (isDown)
            arduino.sendInt(Math.round(stage.mouseX * 100/ stage.stageWidth) )
            trace("---",Math.round(stage.mouseX * 100/ stage.stageWidth))

var _timer:Timer = new Timer(50,2000);

_timer.addEventListener(TimerEvent.TIMER,onTimer, false , 0 , true);

function onArduinoData( event:DataEvent ):void
      trace( "onArduinoData", );

anyone knows of a way to fix this? Thanks in advance

Are you restarting serProxy after open/closing the Serial Monitor?