Jump to content
Search Community

Recommended Posts

Posted

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.

Posted

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.

Posted

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" }

 

???

  • 3 years later...
Posted
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);

  • Like 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...