Can I use include in actionscript in some form?
var somevar = include "file.json";
Where "file.json" contains JSON data
It's not this simple, but possible. First, you have to embed a JSON file as is:
[Embed(source = 'file.json', mimeType='application/octet-stream')]
private static const YourJSON:Class;
Then, to get whatever is embedded (a String, a Bitmap, an SWF), you need to instantiate a variable with this type.
var somevar:String=new YourJSON();
Then you need to parse the JSON, the correct syntax for this varies by JSON and parsing library (this part is mainly determined by your Flash player target). RafH's answer has a syntax for an array and (IIRC) FP10 compatible library.
Also may want use ASC 2.0. (from here) New syntax allows you to use:
var h:Object = include 'conf.json'; // where conf.json contains correct JSON
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With