I just started using JSON and haven't had any problems. found a tutorial to get
me started(not sure where though) and i have it working in a project. here is
the script for importing the class and decoding the data:
import com.adobe.serialization.json.JSON;
var JSONData:Array = new Array();
var bURL:String = "yourDataFile.json";
var bReq:URLRequest = new URLRequest(bURL);
var bLoader:URLLoader = new URLLoader(bReq);
bLoader.addEventListener(Event.COMPLETE, JSONLoaded);
bLoader.addEventListener(IOErrorEvent.IO_ERROR, JSONFailed);
function JSONLoaded(evt:Event):void {
trace("json loaded");
JSONData = JSON.decode(bLoader.data);
//now do something with JSONData
}
function JSONFailed(evt:Event):void {
trace("json failed");
}
hope it helps.
david
> Date: Mon, 12 Oct 2009 22:38:28 -0500
> From: [email protected]
> To: [email protected]
> Subject: Re: [Flashcoders] totally lost figuring out AS3 JSON Class
>
> Thanks Muzak. Yeah, I got the JSON library from the same place.
>
> Muzak wrote:
> > AFAIK, there are no Flex specific classes in the AS3CoreLib library,
> > it's an ActionScript 3 library (hence the name).
> > But yes, you have to make sure it's in the class path to be able to
> > use it, just like any other classes.
> > You can use the .as source files (com folder) or the .swc, whichever
> > you prefer.
> >
> > Did you get the library from googlecode?
> > http://code.google.com/p/as3corelib/downloads/list
> >
> >
> >
> > ----- Original Message ----- From: "Andrew Sinning"
> > <[email protected]>
> > To: "Flash Coders List" <[email protected]>
> > Sent: Tuesday, October 13, 2009 2:02 AM
> > Subject: Re: [Flashcoders] totally lost figuring out AS3 JSON Class
> >
> >
> >> I don't have com.adobe.serialization.json in my install of Flash.
> >> So, I just move the com folder from the as3corelib into my global
> >> classpath and then I can use any of the Flex classes?
> >>
> >> Muzak wrote:
> >>> It's AS3, so not just Flex specific.
> >>>
> >>> There's an example here:
> >>> http://code.google.com/p/as3corelib/source/browse/trunk/examples/JSONExample/JSONExample.mxml
> >>>
> >>>
> >>>
> >
> > _______________________________________________
> > Flashcoders mailing list
> > [email protected]
> > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
> >
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_________________________________________________________________
Learn how to add other email accounts to Hotmail in 3 easy steps.
http://clk.atdmt.com/UKM/go/167688463/direct/01/_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders