Skip to main content
March 16, 2014
Question

Load and display data from JSON file.

  • March 16, 2014
  • 1 reply
  • 5647 views

So I have this json file with a name demo.json

It is basically a notepad file with text:


{

"type":"Toy",

"animal": "Bear",

"data": {

"name": "Timmy",

"color": "Brown",

"price": "10",

"madein": "USA"

}

}



And I need this data to be loaded and displayed in flash swf file. Maybe there is someone who knows how it could be done?

This topic has been closed for replies.

1 reply

Inspiring
March 16, 2014

1. Use URLLoader to load this file.

2. Once it is loaded use JSON class to parse received file.

Here is JSON documentation:

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/JSON.html

March 16, 2014

Thank You!

Will this be correct ?

//import Jason.as class

import com.adobe.serialization.json.JSON

var loader:URLLoader = new URLLoader();

var request:URLRequest = new URLRequest();

 

request.url = "demo.json";

loader.load(request);

loader.addEventListener(Event.COMPLETE, decodeJSON);

Inspiring
March 16, 2014

Yes, it look right (although incomplete).