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
|
@ -25,23 +25,23 @@
|
||||||
|
|
||||||
package scratch {
|
package scratch {
|
||||||
import blocks.*;
|
import blocks.*;
|
||||||
|
|
||||||
import filters.FilterPack;
|
import filters.FilterPack;
|
||||||
|
|
||||||
import flash.display.*;
|
import flash.display.*;
|
||||||
import flash.events.MouseEvent;
|
import flash.events.MouseEvent;
|
||||||
import flash.geom.ColorTransform;
|
import flash.geom.ColorTransform;
|
||||||
import flash.utils.*;
|
import flash.utils.*;
|
||||||
|
|
||||||
import interpreter.*;
|
import interpreter.*;
|
||||||
|
|
||||||
import scratch.ScratchComment;
|
import scratch.ScratchComment;
|
||||||
import scratch.ScratchSprite;
|
import scratch.ScratchSprite;
|
||||||
|
|
||||||
import translation.Translator;
|
import translation.Translator;
|
||||||
|
|
||||||
import util.*;
|
import util.*;
|
||||||
|
|
||||||
import watchers.*;
|
import watchers.*;
|
||||||
|
|
||||||
public class ScratchObj extends Sprite {
|
public class ScratchObj extends Sprite {
|
||||||
|
@ -133,11 +133,19 @@ public class ScratchObj extends Sprite {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isCostumeNameUsed(name:String):Boolean {
|
public function isCostumeNameUsed(name:String):Boolean {
|
||||||
var existingNames:Array = [];
|
name = name.toLowerCase();
|
||||||
for each (var c:ScratchCostume in costumes) {
|
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 {
|
public function unusedCostumeName(baseName:String = ''):String {
|
||||||
|
|
|
@ -664,7 +664,7 @@ public class ScratchRuntime {
|
||||||
public function renameSound(s:ScratchSound, newName:String):void {
|
public function renameSound(s:ScratchSound, newName:String):void {
|
||||||
var obj:ScratchObj = app.viewedObj();
|
var obj:ScratchObj = app.viewedObj();
|
||||||
var oldName:String = s.soundName;
|
var oldName:String = s.soundName;
|
||||||
if (obj.isCostumeNameUsed(newName)) return;
|
if (obj.isSoundNameUsed(newName)) return;
|
||||||
s.soundName = newName;
|
s.soundName = newName;
|
||||||
allUsesOfSoundDo(oldName, function (a:BlockArg):void {
|
allUsesOfSoundDo(oldName, function (a:BlockArg):void {
|
||||||
a.setArgValue(newName);
|
a.setArgValue(newName);
|
||||||
|
|
Loading…
Reference in a new issue