title: Making an function that runs a MC based on a value coming in through an XML socket
body: <p>I have a value coming in through an XML SocketServer, it varies between 0 and 1. 
  I want it to play a movieclip every time it changes. It will change every 30 seconds, but like I said, I want it to do an action every time it changes from 0 to 1 and from 1 to 0 again. I've tried something as you can see in the snippet under, but it didn't really work that well. Now my movieclip appears when its 1 (which means for 30 seconds), then disappears for 30 seconds. </p>
  
  <p>P.S. Probably some bracket errors etc in the code, had to copy/paste from different places in Flash, but it works except what I want to happen above.</p>
  
  <p>-- Amundsen</p>
  
  <pre><code>import swap.MC;
  
  
  var xmlSocket:XMLSocket = new XMLSocket();
  
  xmlSocket.connect("172.16.7.3", 3000);
  xmlSocket.addEventListener(DataEvent.DATA, onIncomingData);
  
  
  function onIncomingData(event:DataEvent):void
  {   
  {
  var OSCPACKET:XML = new XML(event.data);
  trace(OSCPACKET);
  
  var swap;
  
  for each (var property:XML in OSCPACKET)
  {
  
  //Switch Message
  swap = property.MESSAGE.(@NAME == "switch_message").ARGUMENT.@VALUE;
  trace(swap);
  if(swap != laststate)
  {
  swapmsg.visible = true;
  trace("asdasd");
  swapmsg.gotoAndStop(2);
  laststate = swap;
  swapmsg.visible = false;
  }
  </code></pre>