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 {
|
||||
import flash.display.*;
|
||||
import flash.events.*;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.external.ExternalInterface;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.media.*;
|
||||
import flash.net.*;
|
||||
import flash.system.System;
|
||||
|
@ -36,6 +36,7 @@ import flash.geom.Rectangle;
|
|||
import primitives.VideoMotionPrims;
|
||||
import sound.ScratchSoundPlayer;
|
||||
import ui.media.MediaInfo;
|
||||
import ui.BlockPalette;
|
||||
import uiwidgets.DialogBox;
|
||||
import util.*;
|
||||
import watchers.*;
|
||||
|
@ -202,19 +203,25 @@ public class ScratchRuntime {
|
|||
}
|
||||
|
||||
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 = [];
|
||||
allStacksAndOwnersDo(function (stack:Block, target:ScratchObj):void {
|
||||
stack.allBlocksDo(function (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);
|
||||
}
|
||||
}
|
||||
});
|
||||
stack.allBlocksDo(addBlock);
|
||||
});
|
||||
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();
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue