title: learning string arguments, Flash AS3
body: <p>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.</p>
  <h1>XML</h1>
  <pre><code>    &lt;head&gt;
      &lt;/head&gt;
      &lt;body&gt;
      &lt;cnt&gt;1count*count/10&lt;/cnt&gt;
      &lt;/body&gt;
  </code></pre>
  <h1>IS THIS RIGHT?<br></h1>
  <pre><code>                    //XML ==&gt; STRING   
  var string_tangle:String = xml_msg.body.cnt; //LINE 27
  
                      //STRING ==&gt; url request    
  var urlReq:URLRequest = new URLRequest(string_tangle); //LINE 28
  
                      //VALUE ==&gt;       
  fcount=int(urlReq);&lt;br&gt; //GOES TO LINE 49 &quot;urlReq instead of (1count*count/10)&quot;
   
  </code></pre>
  <p><strong>myloader.swf</strong><br></p>
  <pre><code>//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(&quot;localhost&quot;, 1999);
  
  //MY SOCKET
  function socket_event_catcher(Event):void
  {
      switch(Event.type)
      {
          case 'ioError':
              trace(&quot;ioError: &quot; + Event.text);  //Unable to Connect :(//
              break;
          case 'connect':
              trace(&quot;Connection Established!&quot;);  //Connected :)//
              break;
          case 'data':
              trace(&quot;Received Data: &quot; + 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(&quot;Connection Closed!&quot;); //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 (&quot;0000000&quot; + whole).substr(-7, 7) + &quot;.&quot; + (fraction &lt; 10 ? &quot;0&quot; + fraction : fraction); 
  }
  </code></pre>
  <p><strong>ERRORS &quot;may have broke something. It worked fine before I rewrote it.</strong><br>
  security sandbox violation<br>
  Error #2031: Socket Error</p>