mirror of
https://github.com/scratchfoundation/scratch-flash.git
synced 2024-12-12 09:01:18 -05:00
Implemented isSoundNameUsed and fixed a copy-paste error
This commit is contained in:
parent
e369c214ac
commit
4552c5e0b0
2 changed files with 18 additions and 10 deletions
|
@ -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 {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue