// ********************************************************************************
// utility actionscript: spacebox client interaction
// mathias ochsendorf : ochsendorf@hbt.arch.ethz.ch
// october 2004
// ********************************************************************************
// public methods
// ---------------
//
// set the level of individual elements (lights/window):
// ********************************************************************************
// example: switchRedhell(NR1, 80);
MovieClip.prototype.switchRedhell = function(target,aValue){
trace("set level of "+ target + " to:" + aValue);
if(target != undefined && target == "all"){
switchAll();
}
else{
sockOsgi.send(""+ target + "setLevel"+ aValue + "");
}
}
// neon lamp #1
MovieClip.prototype.switchNR1 = function(aValue){
trace("set level of NR1 to:" + aValue);
sockOsgi.send("NR1setLevel"+ aValue + "");
}
MovieClip.prototype.NR1 = function(aValue){
switchNR1(aValue);
}
// neon lamp #2
MovieClip.prototype.switchNR2 = function(aValue){
trace("set level of NR2 to:" + aValue);
sockOsgi.send("NR2setLevel"+ aValue + "");
}
MovieClip.prototype.NR2 = function(aValue){
switchNR2(aValue);
}
// neon lamp #3
MovieClip.prototype.switchNR3 = function(aValue){
trace("set level of NR3 to:" + aValue);
sockOsgi.send("NR3setLevel"+ aValue + "");
}
MovieClip.prototype.NR3 = function(aValue){
switchNR3(aValue);
}
// neon lamp #4
MovieClip.prototype.switchNR4 = function(aValue){
trace("set level of NR4 to" + aValue);
sockOsgi.send("NR4setLevel"+ aValue + "");
}
MovieClip.prototype.NR4 = function(aValue){
switchNR4(aValue);
}
// neon lamp #5
MovieClip.prototype.switchNR5 = function(aValue){
trace("set level of NR5 to:" + aValue);
sockOsgi.send("NR5setLevel"+ aValue + "");
}
MovieClip.prototype.NR5 = function(aValue){
switchNR5(aValue);
}
// spotlight #1
MovieClip.prototype.switchLS1 = function(aValue){
trace("set level of LS1 to:" + aValue);
sockOsgi.send("LS1setLevel"+ aValue + "");
}
MovieClip.prototype.LS1 = function(aValue){
switchLS1(aValue);
}
// spotlight #2
MovieClip.prototype.switchLS2 = function(aValue){
trace("set level of LS2 to:" + aValue);
sockOsgi.send("LS2setLevel"+ aValue + "");
}
MovieClip.prototype.LS2 = function(aValue){
switchLS2(aValue);
}
// spotlight #3
MovieClip.prototype.switchLS3 = function(aValue){
trace("set level of LS3 to:" + aValue);
sockOsgi.send("LS3setLevel"+ aValue + "");
}
MovieClip.prototype.LS3 = function(aValue){
switchLS3(aValue);
}
// spotlight #4
MovieClip.prototype.switchLS4 = function(aValue){
trace("set level of LS4 to:" + aValue);
sockOsgi.send("LS4setLevel"+ aValue + "");
}
MovieClip.prototype.LS4 = function(aValue){
switchLS4(aValue);
}
// spotlight #5
MovieClip.prototype.switchLS5 = function(aValue){
trace("set level of LS5 to:" + aValue);
sockOsgi.send("LS5setLevel"+ aValue + "");
}
MovieClip.prototype.LS5 = function(aValue){
switchLS5(aValue);
}
// spotlight #6
MovieClip.prototype.switchLS6 = function(aValue){
trace("set level of LS6 to:" + aValue);
sockOsgi.send("LS6setLevel"+ aValue + "");
}
MovieClip.prototype.LS6 = function(aValue){
switchLS6(aValue);
}
// spotlight #7
MovieClip.prototype.switchLS7 = function(aValue){
trace("set level of LS7 to:" + aValue);
sockOsgi.send("LS7setLevel"+ aValue + "");
}
MovieClip.prototype.LS7 = function(aValue){
switchLS7(aValue);
}
// spotlight #8
MovieClip.prototype.switchLS8 = function(aValue){
trace("set level of LS8 to:" + aValue);
sockOsgi.send("LS8setLevel"+ aValue + "");
}
MovieClip.prototype.LS8 = function(aValue){
switchLS8(aValue);
}
// spotlight #9
MovieClip.prototype.switchLS9 = function(aValue){
trace("set level of LS9 to:" + aValue);
sockOsgi.send("LS9setLevel"+ aValue + "");
}
MovieClip.prototype.LS9 = function(aValue){
switchLS9 (aValue);
}
// spotlight #10
MovieClip.prototype.switchLS10 = function(aValue){
trace("set level of LS10 to:" + aValue);
sockOsgi.send("LS10setLevel"+ aValue + "");
}
MovieClip.prototype.LS10 = function(aValue){
switchLS10(aValue);
}
// window
MovieClip.prototype.switchWindow = function(aValue){
trace("set level of WINDOW to:" + aValue);
sockOsgi.send("WINDOWsetLevel"+ aValue + "");
}
MovieClip.prototype.WINDOW = function(aValue){
switchWindow(aValue);
}
// switch all lights
MovieClip.prototype.switchAll = function(aValue){
trace("set level of all devices to:" + aValue);
sockOsgi.send("NR1setLevel"+ aValue + "NR2setLevel"+ aValue + "NR3setLevel"+ aValue + "NR4setLevel"+ aValue + "NR5setLevel"+ aValue + "LS1setLevel"+ aValue + "LS2setLevel"+ aValue + "LS3setLevel"+ aValue + "LS4setLevel"+ aValue + "LS5setLevel"+ aValue + "LS6setLevel"+ aValue + "LS7setLevel"+ aValue + "LS8setLevel"+ aValue + "LS9setLevel"+ aValue + "LS10setLevel"+ aValue + "");
}
// react on server responses containing status change information
// ********************************************************************************
function processResponse(node){
if(node.nodeName == osgiPrefix + "message" || node.nodeName == osgiPrefix + "rcbox" )
{
traverse_XML_message(node);
trace("processResponse value of " + myNodeID + " changed to: " + myNodeValue);
//===
// do something with that information
//===
//if(myNodeID==0){
// gotoAndStop(1);
//}
//else if(myNodeID=="NR1"){
// gotoAndPlay(4);
//}
//else if(myNodeID=="NR2"){
// gotoAndStop(3);
//}
//else {
// gotoAndStop(1);
//}
return;
}
if(!node.hasChildNodes()) return;
var n = node.firstChild;
do{processResponse(n);} while(n = n.nextSibling);
}
// global variables and socket connections
// ********************************************************************************
if (!_global.initialize)
{
trace("template is loaded");
_global.initialize = true;
_global.osgiServer = "styropor.ethz.ch";
_global.osgiPort = 4445;
_global.osgiPrefix = "";
sockOsgi = new XMLSocket();
sockOsgi.onXML = onSockMessage;
sockOsgi.onConnect = onSockConnectOsgi;
sockOsgi.onClose = onSockCloseOsgi;
sockOsgi.returnField = "\n ";
sockOsgi.connect(osgiServer, osgiPort);
}
// background functionality
// ********************************************************************************
// a message from the server received
function onSockMessage(xml_response) {
processResponse(xml_response);
}
// connect to the server
function onSockConnectOsgi(success)
{
if (success)
{
trace ("connected to osgi server ");
} else {
trace ("connection to osgi server failed");
}
}
// disconnection from the server
function onSockCloseOsgi() {
trace ("lost connection to osgi server");
}
// send a message to the server
// @param array with the element ids
// @param the invoked method
// @param the value
function sendSockXML(myIDs, myMethod, myValue) {
message = new XML();
message_spacebox = message.createElement("spacebox");
message_request = message.createElement("request");
for (i=0; i