我创建了一个音乐播放闪光灯,它很好用,当我从我的本地存储器运行它时(即直接从我的电脑打开swf) 但是当我从服务器打开swf时,它不会加载文件。我在下面添加了输入处理程序。
function addTrack(){
var trackChecker: URLLoader = new URLLoader();
if (String(path.text).substr(-4, 4) == ".mp3") {
txtError.text = "";
trackChecker.load(new URLRequest(String(path.text)))
} else {
if (String(path.text).substr(-4, 1) == ".") {
txtError.text = "Wrong format, tried to open " + String(path.text).substr(-4, 4) + ", but the only currently supported format is .mp3";
} else {
path.appendText(".mp3");
txtError.text = "";
trackChecker.load(new URLRequest(String(path.text)))
}
}
trackChecker.addEventListener(Event.COMPLETE, addToList);
trackChecker.addEventListener(IOErrorEvent.IO_ERROR, onIOError);
}
function onIOError(e: IOErrorEvent) {
txtError.text = "No file found or file is damaged";
}
function addToList(e: Event) {
addedTrack = true;
tempSong = new Sound();
tempSong.load(new URLRequest(String(path.text)));
tempSong.addEventListener(Event.COMPLETE, tempData);
ActualArray[ActualArray.length] = ["Placeholder", "Placeholder", "Placeholder", "Placeholder", String(path.text)];
}
function tempData(e: Event) {
var tempTrackName;
var tempName: Array = tempSong.url.split("/");
if (String(tempSong.id3.songName) == "null") {
tempTrackName = String(tempName[tempName.length - 1].replace(".mp3", ""));
} else {
tempTrackName = (String(tempSong.id3.songName));
}
path.text = "";
for (var i: int = 3; i < tA.length - 1; i++) {
path.appendText(tempName[i]);
path.appendText("\\");
}
addToGrid(int(ActualArray.length - 1), tempSong.length, tempTrackName);
path.setSelection(path.text.length, path.text.length);
}
值得注意的是脚本在它可以改变path.text之前停止,即在&#34;函数tempData(e:Event)&#34;的中间。或更早。在停止我意味着什么都没有发生,其他脚本工作,但当你尝试添加一个轨道时根本没有任何事情发生。但是我无法在我的计算机上重新创建故障,因为它仅在swf在外部托管时才存在。