Merge pull request #248 from djdolphin/validate-attributes

Make attribute block update when switching sprites
This commit is contained in:
Nathan Dinsmore 2014-06-24 12:18:10 -04:00
commit 20d24f2a63

View file

@ -413,6 +413,13 @@ public class BlockMenus implements DragClient {
else if (s == 'myself') blockArg.setArgValue('_myself_', Translator.map('myself')); else if (s == 'myself') blockArg.setArgValue('_myself_', Translator.map('myself'));
else if (s == 'Stage') blockArg.setArgValue('_stage_', Translator.map('Stage')); else if (s == 'Stage') blockArg.setArgValue('_stage_', Translator.map('Stage'));
else blockArg.setArgValue(s); else blockArg.setArgValue(s);
if (block.op == 'getAttribute:of:') {
var obj:ScratchObj = app.stagePane.objNamed(s);
var attr:String = block.args[0].argValue;
var validAttrs:Array = obj.isStage ? ['backdrop #', 'background #', 'backdrop name', 'volume'] :
['x position', 'y position', 'direction', 'costume #', 'costume name', 'size', 'volume'];
if ((validAttrs.indexOf(attr) == -1) && !obj.ownsVar(attr)) block.args[0].setArgValue(obj.isStage ? 'backdrop #' : 'x position');
}
Scratch.app.setSaveNeeded(); Scratch.app.setSaveNeeded();
} }
var spriteNames:Array = []; var spriteNames:Array = [];