title: actionscript 3 and JSON
body: <p>I've been trying to get JSON working with AS3 for a while now, but to no avail.  I keep getting the following error when I get the JSON back:</p>
  
  <p>TypeError: Error #1034: Type Coercion failed: cannot convert Object@26331c41 to Array.</p>
  
  <p>I've tried changing the datatype of the variable "jsonData" to object, which fixes the error, but I'm not entirely sure how I can parse the data. </p>
  
  <pre><code>package 
  {
      import flash.display.Sprite;
      import flash.net.URLRequest;
      import flash.net.URLLoader;
      import flash.events.*;
      import com.adobe.serialization.json.JSON; 
  
      public class DataGrab extends Sprite {
  
          public function DataGrab() {
  
          }
  
          public function init(resource:String):void {
              var loader:URLLoader = new URLLoader();
              var request:URLRequest = new URLRequest(resource);
              loader.addEventListener(Event.COMPLETE, onComplete);
              loader.load(request);
          }   
  
          private function onComplete(e:Event):void {
              var loader:URLLoader = URLLoader(e.target);
              var jsonData:Array = JSON.decode(loader.data);
              trace(jsonData);
          }
  
  
      }
  }
  </code></pre>