diff --git a/src/scratch/ScratchObj.as b/src/scratch/ScratchObj.as index 4313dee..3e99861 100644 --- a/src/scratch/ScratchObj.as +++ b/src/scratch/ScratchObj.as @@ -25,23 +25,23 @@ package scratch { import blocks.*; - + import filters.FilterPack; - + import flash.display.*; import flash.events.MouseEvent; import flash.geom.ColorTransform; import flash.utils.*; - + import interpreter.*; - + import scratch.ScratchComment; import scratch.ScratchSprite; import translation.Translator; - + import util.*; - + import watchers.*; public class ScratchObj extends Sprite { @@ -133,11 +133,19 @@ public class ScratchObj extends Sprite { } public function isCostumeNameUsed(name:String):Boolean { - var existingNames:Array = []; + name = name.toLowerCase(); for each (var c:ScratchCostume in costumes) { - existingNames.push(c.costumeName.toLowerCase()); + if (c.costumeName.toLowerCase() == name) return true; } - return (existingNames.indexOf(name.toLowerCase()) > -1); + 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 { diff --git a/src/scratch/ScratchRuntime.as b/src/scratch/ScratchRuntime.as index 2b99651..29b9750 100644 --- a/src/scratch/ScratchRuntime.as +++ b/src/scratch/ScratchRuntime.as @@ -664,7 +664,7 @@ public class ScratchRuntime { public function renameSound(s:ScratchSound, newName:String):void { var obj:ScratchObj = app.viewedObj(); var oldName:String = s.soundName; - if (obj.isCostumeNameUsed(newName)) return; + if (obj.isSoundNameUsed(newName)) return; s.soundName = newName; allUsesOfSoundDo(oldName, function (a:BlockArg):void { a.setArgValue(newName);