My swf listens to XML from a socket and document. How do I get 'my variables' to grab XML from the socket instead of the XML document?
ANSWER
I'm confused with setting up the variables, and there values. There's nothing wrong with the document, "I'm just stuck." I plan to do a lot of reading after all this research.
PURPOSE
My purpose is to control variables with a XML Socket Server. I hope my question is clear, but ask if there's any questions.
EXAMPLE
Flash File
import flash.net.*;
import flash.display.*;
import flash.events.*;
import flash.system.Security;
import flash.utils.Timer;
import flash.events.TimerEvent;
//MY VARIABLES, LINE 8-12
var timer:Timer = new Timer(10);
var myString:String = "";
var count:int = 0;
var myStg:String = "";
var fcount:int = 0;
var xml_s=new XMLSocket();
xml_s.addEventListener(Event.CONNECT, socket_event_catcher);//OnConnect//
xml_s.addEventListener(Event.CLOSE, socket_event_catcher);//OnDisconnect//
xml_s.addEventListener(IOErrorEvent.IO_ERROR, socket_event_catcher);//Unable To Connect//
xml_s.addEventListener(DataEvent.DATA, socket_event_catcher);//OnDisconnect//
xml_s.connect("localhost", 1999);
function socket_event_catcher(Event):void {
switch (Event.type) {
case 'ioError' :
trace("ioError: " + Event.text);//Unable to Connect :(//
break;
case 'connect' :
trace("Connection Established!");//Connected :)//
break;
case 'data' :
trace("Received Data: " + Event.data);
break;
case 'close' :
trace("Connection Closed!");//OnDisconnect :( //
xml_s.close();
break;
}
}
//LOAD XML
var myXML:XML;
var myLoader:URLLoader = new URLLoader();
myLoader.load(new URLRequest("time.xml"));
myLoader.addEventListener(Event.COMPLETE, processXML);
//PARSE XML
function processXML(e:Event):void {
myXML = new XML(e.target.data);
trace(myXML.COUNT.text()); //-77777
//grab the data as a string
myString = myXML.COUNT.text()
//grab the data as an int
count = int(myXML.COUNT.text());
//grab the data as a string
myString = myXML.COUNT.text()
//grab the data as an int
count = int(myXML.COUNT.text());
//grab the data as a string
myStg = myXML.COUNT.text()
//grab the data as an int
fcount = int(myXML.COUNT.text());
//grab the data as a string
myStg = myXML.COUNT.text()
//grab the data as an int
fcount = int(myXML.COUNT.text());
trace("String: ", myString);
trace("Int: ", count);
trace(count - 1); //just to show you that it's a number that you can do math with (-77778)
//TEXT
var text:TextField = new TextField();
text.text = myString;
addChild(text);
}
Ruby Server 'Snippet'
msg1 = {"msg" => {"head" => {"type" => "frctl", "seq_no" => seq_no, "version" => 1.0},
"SESSION" => {"text" => "88888", "timer" => -1000,
"count" => 10, "fcount" => "10"}}}
XML
<?xml version="1.0" encoding="utf-8"?>
<SESSION>
<TIMER TITLE="speed">100</TIMER>
<COUNT TITLE="starting position">88888</COUNT>
<FCOUNT TITLE="ramp">1000</FCOUNT>
</SESSION>
Here's a link
http://videodnd.weebly.com/
If you're interested, you can install Ruby 186-25.
a. Install Ruby
b. Run policyserver.rb first
c. flashserver next.rb
d. CTRL_ENTER socketServer.fla
PROBLEM
Coding errors "coercion of value"