Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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);
Copy link to clipboard
Copied
Yes, it look right (although incomplete).
Copy link to clipboard
Copied
Ok, so I make 6 dynamic text fields in AS3 with instance names
type.txt
animal.txt
name.txt
color.txt
price.txt
madein.txt
and I need the data from JSON file to be displayed into those text fields.
Coud You please tell me what would be the correct code for that?
Copy link to clipboard
Copied
1. Do not use special characters in variables names (remove dots from instances names).
2. What did you do so far? Do you know how to create text fields and write values into them?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now