# Arduino with Flash CS 4 ActionScript 3.0

**URL:** <https://forum.kirupa.com/t/arduino-with-flash-cs-4-actionscript-3-0/308009>\
**Category:** flash\
**Created:** [April 15, 2010, 2:11am UTC](https://forum.kirupa.com/t/arduino-with-flash-cs-4-actionscript-3-0/308009 "2010-04-15T02:11:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![asilloo](https://avatars.discourse-cdn.com/v4/letter/a/cdc98d/32.png) [@asilloo](https://forum.kirupa.com/u/asilloo)\
**Post date:** [April 15, 2010, 2:11am UTC](https://forum.kirupa.com/t/arduino-with-flash-cs-4-actionscript-3-0/308009/1 "2010-04-15T02:11:15Z")

</div>

Hi,

This is the code that I wrote in flash MX:

import flash.events._;  
import flash.errors._;  
import flash.net.Socket;

stop();

var magnetic:Socket=new Socket(“localhost”,5331);  
var magneticValue:Number=0;  
var newText:TextField= new TextField();

magnetic.addEventListener(Event.CLOSE, closeConnection);  
magnetic.addEventListener(Event.CONNECT, connectionStart);  
magnetic.addEventListener(IOErrorEvent.IO\_ERROR, errorConnection);  
magnetic.addEventListener(SecurityErrorEvent.SECUR ITY\_ERROR, securityConnection);  
magnetic.addEventListener(ProgressEvent.SOCKET\_DAT A, dataConnection);

```
 function readResponse():void {
       
       //magneticValue=parseInt(magnetic.readUTFBytes(magne tic.bytesAvailable);            
       
       magneticValue=magnetic.readInt(magnetic.bytesAvailable); // IN THIS LINE I HAVE A PROBLEM, 
       
       trace(magneticValue);
       }

```

function closeConnection(event:Event):void {  
trace("closeConnection: " + event);  
}

function connectionStart(event:Event):void {  
trace("connectionStart: " + event);  
}

function errorConnection(event:IOErrorEvent):void {  
trace("errorConnection: " + event);  
}

function securityConnection(event:SecurityErrorEvent):void {  
trace("securityConnection: " + event);  
}

function dataConnection(event:ProgressEvent):void {  
trace("dataConnection: " + event);  
readResponse();  
}

* * *

the results that I get from Flash are like;  
Ò  
Ð  
þ  
È  
Ð  
þ  
È  
þ

for be sure I opened HyperTerminal and I connect the program to the port, and the results are normal in HyperTerminal, like ;  
-174  
-174  
-176  
-173  
-176  
-172  
-175  
-176

I’m working in A.S. 3.0, My question is How I can get the value form Arduino as a number (-175) not like (Ð), and if I solved this problem, how I can using them as variable in Flash MX A.S. 3.0
