Reverse target iteration in allScriptsDo

The `allStacksAndOwnersDo` function in Scratch 2.0 runtime iterates
targets in reverse and projects sometimes rely on that for correct
initialization. If, for example, each sprite runs a "go back 999 layers"
or "go to front" block as its first action, the order of execution will
determine the ordering of the layers.

This change makes Scratch 3.0 match the Scratch 2.0 execution order.
This commit is contained in:
Christopher Willis-Ford 2017-02-13 14:35:50 -08:00
parent bd76395676
commit 18107cde7b

View file

@ -414,7 +414,7 @@ Runtime.prototype.allScriptsDo = function (f, optTarget) {
if (optTarget) {
targets = [optTarget];
}
for (var t = 0; t < targets.length; t++) {
for (var t = targets.length - 1; t >= 0; t--) {
var target = targets[t];
var scripts = target.blocks.getScripts();
for (var j = 0; j < scripts.length; j++) {