Discuss Scratch

turkey3
Scratcher
1000+ posts

JSON and Flash

If Scratch runs on Flash what is the usage of JSON? Is JSON just for project storing whereas Flash interprets the JSON into ActionScript and then machine code? Why wouldn't the ST just make projects saved as raw ActionScript? Wouldn't using JSON makes projects less efficient due to the extra interpretation?

PullJosh
Scratcher
1000+ posts

JSON and Flash

turkey3 wrote:

If Scratch runs on Flash what is the usage of JSON? Is JSON just for project storing whereas Flash interprets the JSON into ActionScript and then machine code? Why wouldn't the ST just make projects saved as raw ActionScript? Wouldn't using JSON makes projects less efficient due to the extra interpretation?
Well, I don't know much about this kind of thing, but it seems to me like the loading would take longer, but after that, the actual running/editing shouldn't be effected.

But really, what do I know?
djdolphin
Scratcher
1000+ posts

JSON and Flash

The json stores the spec for each block and its inputs in an array. It isn't stored as actionscript because not every block has an equivalent in actionscript and had to be coded specifically for easy use. For example, <touching [sprite v]?>, needs to compare the location of pixels for sprites and check if they overlap. If it was stored as actionscript instead of a json array, projects would be many times larger. If they were stored as actionscript, that would also bring up security issues, since people could hack projects to do whatever they want:
while (0 = 0) {
  uiwidgets.DialogBox.notify("Hey!", "Infinite popups!", app.stage);
}
It would also be very difficult to parse the actionscript code to get blocks again.

Last edited by djdolphin (June 11, 2014 01:37:55)


!
davidkt
Scratcher
1000+ posts

JSON and Flash

JSON makes the project format encodable/decodable by all languages while still storing in a binary file for efficiency, so if you want to make a completely new IDE for scratch in a whole new language, then JSON makes that easy.

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
turkey3
Scratcher
1000+ posts

JSON and Flash

djdolphin wrote:

The json stores the spec for each block and its inputs in an array. It isn't stored as actionscript because not every block has an equivalent in actionscript and had to be coded specifically for easy use. For example, <touching [sprite v]?>, needs to compare the location of pixels for sprites and check if they overlap. If it was stored as actionscript instead of a json array, projects would be many times larger. If they were stored as actionscript, that would also bring up security issues, since people could hack projects to do whatever they want:
while (0 = 0) {
  uiwidgets.DialogBox.notify("Hey!", "Infinite popups!", app.stage);
}
It would also be very difficult to parse the actionscript code to get blocks again.
Okay, but then why is Flash needed if JSON stores all the data? If Flash interprets ActionScript, why is Flash needed to interpret the JSON?

davidkt
Scratcher
1000+ posts

JSON and Flash

turkey3 wrote:

djdolphin wrote:

The json stores the spec for each block and its inputs in an array. It isn't stored as actionscript because not every block has an equivalent in actionscript and had to be coded specifically for easy use. For example, <touching [sprite v]?>, needs to compare the location of pixels for sprites and check if they overlap. If it was stored as actionscript instead of a json array, projects would be many times larger. If they were stored as actionscript, that would also bring up security issues, since people could hack projects to do whatever they want:
while (0 = 0) {
  uiwidgets.DialogBox.notify("Hey!", "Infinite popups!", app.stage);
}
It would also be very difficult to parse the actionscript code to get blocks again.
Okay, but then why is Flash needed if JSON stores all the data? If Flash interprets ActionScript, why is Flash needed to interpret the JSON?
*facepalm* Because you need an interface… or else you can't do anything! You can't make even the simplest interface in JSON- it's just storage.

Remember when I looked like this? I still do.


Float, my Scratch 2.0 mod | My (somewhat under-construction) blog
turkey3
Scratcher
1000+ posts

JSON and Flash

davidkt wrote:

turkey3 wrote:

djdolphin wrote:

The json stores the spec for each block and its inputs in an array. It isn't stored as actionscript because not every block has an equivalent in actionscript and had to be coded specifically for easy use. For example, <touching [sprite v]?>, needs to compare the location of pixels for sprites and check if they overlap. If it was stored as actionscript instead of a json array, projects would be many times larger. If they were stored as actionscript, that would also bring up security issues, since people could hack projects to do whatever they want:
while (0 = 0) {
  uiwidgets.DialogBox.notify("Hey!", "Infinite popups!", app.stage);
}
It would also be very difficult to parse the actionscript code to get blocks again.
Okay, but then why is Flash needed if JSON stores all the data? If Flash interprets ActionScript, why is Flash needed to interpret the JSON?
*facepalm* Because you need an interface… or else you can't do anything! You can't make even the simplest interface in JSON- it's just storage.
Well I know that he interface uses Flash, but suppose your just viewing someone else's project and would not need the project editor opened. Flash is still needed because it probably interprets the JSON

Powered by DjangoBB