lddd Posted July 18, 2011 Share Posted July 18, 2011 Hello, i am new to LoaderMax and would like to use it to load JSON Data with different URL Parameters (representing 3 different dataProviders) to use in my Project (3 Comboboxes, that should get filled with the specific JSON Data comming from a webservice). Could someone teach me howto do so. Maybe provide any valid Snippet for this kind of purpose? thanks in advance. Link to comment Share on other sites More sharing options...
Carl Posted July 18, 2011 Share Posted July 18, 2011 to load the data, its pretty straight forward with a DataLoader: http://www.greensock.com/as/docs/tween/ ... oader.html import com.greensock.*; import com.greensock.loading.*; import com.greensock.events.LoaderEvent; //create a DataLoader //change sample.json to url/name of your json file var jsonLoader:DataLoader = new DataLoader("sample.json", {onComplete:showJson}); //load the data jsonLoader.load(); //when file is loaded this function will run function showJson(e:LoaderEvent):void{ //will display the contents of your file in the output window trace(e.target.content); } as far as parsing JSON goes, I don't even know if there is any native AS3 support for that. I think there are some tools out there for it. LoaderMax will load it no problem. Once its loaded you will have to devise a way to get the info you need out of it. Link to comment Share on other sites More sharing options...
lddd Posted July 19, 2011 Author Share Posted July 19, 2011 It works but not for a "Number" Value for my JSON Object... trace(objManufactur[0].key); (WORKS!) { "A": { "key": "Brother", "value": "40" } trace(objSeries[0].key); (FAILS, TypeError: Error #1010:) { "A": { "key": "A", "value": "40" } ??? Link to comment Share on other sites More sharing options...
mike rigley Posted October 1, 2014 Share Posted October 1, 2014 You can (natively) parse JSON -> AS3. Add this into the showJson() function in Carl’s previous example: var myData:Object = JSON.parse(e.target.content); 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now