嘿试图通过串行端口输入数据,但我收到此错误。1037: 包不能嵌套。然后我需要获取这些值并使用 1 来控制视频播放和另一个来控制音量
package
{
import flash.display.Sprite;
import flash.net.XMLSocket;
import flash.events.DataEvent;
public class receiveData extends Sprite
{
public static const PORT:Number = 5331;
public static const COMMA:String = ",";
public static const LOCALHOST:String = "127.0.0.1";
private var socket:XMLSocket = null;
public function receiveData()
{
super();
init();
}
private function init():void
{
socket = new XMLSocket();
socket.addEventListener( DataEvent.DATA, doSocketData );
socket.connect( LOCALHOST, PORT );
}
protected function doSocketData( event:DataEvent ):void
{
var parts:Array = null;
var sensorone:Number = 0;
var sensortwo:Number = 0;
var values:String = event.data.toString();
parts = values.split( COMMA );
trace( parts[0]);
trace( parts[1]);
sensorone = new Number( parts[0] );
sensortwo = new Number( parts[1] );
}
}
}