oldswitch.as

来自「在有名的开源elphel 333 系列网络摄像机基础上」· AS 代码 · 共 57 行

AS
57
字号
XML.prototype.ignoreWhite = true;
socket = new XMLSocket();
socket.onConnect = myOnConnect;
isConnect=0;

if (ip==undefined) {
  ip="192.168.0.90";
}

if (lineid==undefined) {
  lineid="DL1";
}

if (port==undefined) {
  port=7000;
}

function myOnConnect(success) {
  if (success) {
    // Connection succeeded
    var myXML = new XML(); 
    var myLogin = myXML.createElement("setline"); 
    myLogin.attributes.id = _root.lineid; 
  
    if (_root.OldSwitch._currentFrame==1) {
      _root.OldSwitch.gotoAndStop(2);
      myLogin.attributes.state = "on"; 
      myXML.appendChild(myLogin); 
      _root.socket.send(myXML); 
    } else {
      _root.OldSwitch.gotoAndStop(1);
      myLogin.attributes.state = "off"; 
      myXML.appendChild(myLogin); 
      _root.socket.send(myXML); 
    }
  }
  _root.socket.close();
  _root.isConnect=0;
}

OldSwitch.onPress = function () {
  if (_root.isdemo=="yes") {
    if (_root.OldSwitch._currentFrame==1) {
      _root.OldSwitch.gotoAndStop(2);
    } else {
      _root.OldSwitch.gotoAndStop(1);
    }
  }
  
  if (_root.isConnect==1) {
    return;
  }
  _root.isConnect=1;
  if (!_root.socket.connect(_root.ip,_root.port)) {
    return;
  }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?