diff --git a/src/scratch/ScratchObj.as b/src/scratch/ScratchObj.as index 3e99861..721c069 100644 --- a/src/scratch/ScratchObj.as +++ b/src/scratch/ScratchObj.as @@ -132,22 +132,6 @@ public class ScratchObj extends Sprite { return currentCostumeIndex + 1; } - public function isCostumeNameUsed(name:String):Boolean { - name = name.toLowerCase(); - for each (var c:ScratchCostume in costumes) { - if (c.costumeName.toLowerCase() == name) return true; - } - return false; - } - - public function isSoundNameUsed(name:String):Boolean { - name = name.toLowerCase(); - for each (var s:ScratchSound in sounds) { - if (s.soundName.toLowerCase() == name) return true; - } - return false; - } - public function unusedCostumeName(baseName:String = ''):String { // Create a unique costume name by appending a number if necessary. if (baseName == '') baseName = Translator.map(isStage ? 'backdrop1' : 'costume1'); diff --git a/src/scratch/ScratchRuntime.as b/src/scratch/ScratchRuntime.as index abd4231..e34b9c5 100644 --- a/src/scratch/ScratchRuntime.as +++ b/src/scratch/ScratchRuntime.as @@ -676,7 +676,7 @@ public class ScratchRuntime { var obj:ScratchObj = app.viewedObj(); var costume:ScratchCostume = obj.currentCostume(); var oldName:String = costume.costumeName; - if (obj.isCostumeNameUsed(newName)) return; + newName = obj.unusedCostumeName(newName || 'costume1'); costume.costumeName = newName; updateArgs(obj.isStage ? allUsesOfBackdrop(oldName) : allUsesOfCostume(oldName), newName); } @@ -703,7 +703,7 @@ public class ScratchRuntime { public function renameSound(s:ScratchSound, newName:String):void { var obj:ScratchObj = app.viewedObj(); var oldName:String = s.soundName; - if (obj.isSoundNameUsed(newName)) return; + newName = obj.unusedSoundName(newName || 'sound1'); s.soundName = newName; allUsesOfSoundDo(oldName, function (a:BlockArg):void { a.setArgValue(newName);