mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-12 09:01:18 -05:00
Merge pull request #169 from nathan/broadcasts-in-palette
Fixed broadcasts created in palette not being accessible via menu
This commit is contained in:
commit
7a3c45fa2e
1 changed files with 19 additions and 12 deletions
|
@ -23,8 +23,8 @@
|
||||||
package scratch {
|
package scratch {
|
||||||
import flash.display.*;
|
import flash.display.*;
|
||||||
import flash.events.*;
|
import flash.events.*;
|
||||||
import flash.external.ExternalInterface;
|
import flash.external.ExternalInterface;
|
||||||
import flash.geom.Rectangle;
|
import flash.geom.Rectangle;
|
||||||
import flash.media.*;
|
import flash.media.*;
|
||||||
import flash.net.*;
|
import flash.net.*;
|
||||||
import flash.system.System;
|
import flash.system.System;
|
||||||
|
@ -36,6 +36,7 @@ import flash.geom.Rectangle;
|
||||||
import primitives.VideoMotionPrims;
|
import primitives.VideoMotionPrims;
|
||||||
import sound.ScratchSoundPlayer;
|
import sound.ScratchSoundPlayer;
|
||||||
import ui.media.MediaInfo;
|
import ui.media.MediaInfo;
|
||||||
|
import ui.BlockPalette;
|
||||||
import uiwidgets.DialogBox;
|
import uiwidgets.DialogBox;
|
||||||
import util.*;
|
import util.*;
|
||||||
import watchers.*;
|
import watchers.*;
|
||||||
|
@ -202,19 +203,25 @@ public class ScratchRuntime {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function collectBroadcasts():Array {
|
public function collectBroadcasts():Array {
|
||||||
|
function addBlock(b:Block):void {
|
||||||
|
if ((b.op == 'broadcast:') ||
|
||||||
|
(b.op == 'doBroadcastAndWait') ||
|
||||||
|
(b.op == 'whenIReceive')) {
|
||||||
|
if (b.args[0] is BlockArg) {
|
||||||
|
var msg:String = b.args[0].argValue;
|
||||||
|
if (result.indexOf(msg) < 0) result.push(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
var result:Array = [];
|
var result:Array = [];
|
||||||
allStacksAndOwnersDo(function (stack:Block, target:ScratchObj):void {
|
allStacksAndOwnersDo(function (stack:Block, target:ScratchObj):void {
|
||||||
stack.allBlocksDo(function (b:Block):void {
|
stack.allBlocksDo(addBlock);
|
||||||
if ((b.op == 'broadcast:') ||
|
|
||||||
(b.op == 'doBroadcastAndWait') ||
|
|
||||||
(b.op == 'whenIReceive')) {
|
|
||||||
if (b.args[0] is BlockArg) {
|
|
||||||
var msg:String = b.args[0].argValue;
|
|
||||||
if (result.indexOf(msg) < 0) result.push(msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
var palette:BlockPalette = app.palette;
|
||||||
|
for (var i:int = 0; i < palette.numChildren; i++) {
|
||||||
|
var b:Block = palette.getChildAt(i) as Block;
|
||||||
|
if (b) addBlock(b);
|
||||||
|
}
|
||||||
result.sort();
|
result.sort();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue