I'm bad with strings and probably messed this up. My Flash file receives XML commands and changes the value of the animations (speed, time). Can you improve this string argument or give me an idea what I need to do differently.
XML
<head>
</head>
<body>
<cnt>1count*count/10</cnt>
</body>
IS THIS RIGHT?
//XML ==> STRING
var string_tangle:String = xml_msg.body.cnt; //LINE 27
//STRING ==> url request
var urlReq:URLRequest = new URLRequest(string_tangle); //LINE 28
//VALUE ==>
fcount=int(urlReq);<br> //GOES TO LINE 49 "urlReq instead of (1count*count/10)"
myloader.swf
//METHODS
import flash.net.*;
import flash.display.Loader;
import flash.events.*;
import flash.system.Security;
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);
//MY SOCKET
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);
var xml_msg:XML = new XML(Event.data);
var string_tangle:String = xml_msg.body.cnt;
var urlReq:URLRequest = new URLRequest(string_tangle);
//fcount=int(urlReq);
break;
case 'close':
trace("Connection Closed!"); //OnDisconnect :( //
xml_s.close();
break;
}
}
//////////////////////////////////////////////////////////////
//MY TIMER
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
var fcount:int = 0;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(event:TimerEvent) {
count++;
//WANT TO CHANGE THIS IN LINE 50//fcount=int(urlReq);
fcount=int(count*count/1000);
mytext.text = formatCount(fcount);
}
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction);
}
ERRORS "may have broke something. It worked fine before I rewrote it.
security sandbox violation
Error #2031: Socket Error