title: YouTube ActionScript 3.0 API getting the state from onStateChange
body: <p>According to the <a href="https://developers.google.com/youtube/flash_api_reference#Events" rel="nofollow">YouTube ActionScript 3.0 Player API</a>, the onStateChange event returns a signed integer from -1 to 5, however I am having problems getting at that integer.</p>
  
  <p>ActionScript 3.0 code:</p>
  
  <pre><code>loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
  loader.load(new URLRequest("http://www.youtube.com/apiplayer?version=3&amp;modestbranding=true"));
  
  function onLoaderInit(event:Event):void{
      loader.content.addEventListener("onStateChange", onPlayerStateChange);
  }
  
  function onPlayerStateChange(event):void{
      trace(event);
  }
  </code></pre>
  
  <p>This trace gives me the following output:</p>
  
  <pre><code>[Event type="onStateChange" bubbles=false cancelable=false eventPhase=2]
  [Event type="onStateChange" bubbles=false cancelable=false eventPhase=2]
  [Event type="onStateChange" bubbles=false cancelable=false eventPhase=2]
  </code></pre>
  
  <p>The ActionScript code works fine, its just getting at the state value that I am struggling with.</p>
  
  <p>The only property that kinda looks like what I want is the <code>eventPhase</code> property, but I know its not this as its the same value every time (the API states that the first state returned will be -1) and its also an unsigned integer.</p>
  
  <p>Can anyone tell me how to get at the value I need?</p>