actionscript 3 - AS3 Array issue and Arduino -
i hoping can me issue having as3 script, new , apologizes if there simple answer
import flash.net.socket; import flash.events.event; var mysocket:socket = new socket(); mysocket.connect("127.0.0.1",5331);; mysocket.addeventlistener(progressevent.socket_data, socketdatahandler); var buffer:string = ""; function socketdatahandler(event:progressevent):void { var str:string = string(mysocket.readutfbytes(mysocket.bytesavailable)); var array:array = new array(); buffer += str; array = buffer.split(","); var textpwm:array = new array; var textpercentage:array = new array; var textvoltage:array = new array; textpwm.push(array[0]); textpercentage.push(array[1]); textvoltage.push(array[2]); var pwm_a:string; pwm_a = textpwm.join(""); var percentage_a:string; percentage_a = textpercentage.join(""); var voltage_a:string; voltage_a = textvoltage.join(""); pwmbox.text = pwm_a; percentagebox.text = percentage_a + "%"; voltagebox.text = voltage_a + "v"; trace(textpwm); }
this code as3 script have tried debug code , have found out arrays
var textpwm:array = new array; var textpercentage:array = new array; var textvoltage:array = new array;
always hold same values when new data sent arduino array known "array" change new values come in others keep same data on , on again
if can great
thank
"buffer" global variable (every time when call buffer += str; add new data after existing one) use buffer = str;
instead of += or array = str.split(",");
can remove lot of code, like: pwmbox.text = array[0] + " v;"
example;
Comments
Post a Comment