建议场景大小200*200,背景0x000000

//*******************************************//
//james.li 2004-7-18//
//*******************************************//
init();
//*******************************************************初始化部分************************************************************//
function init() {
 System.useCodepage = true;
 initProtos();
 initFscommands();
 initVariables();
 initSharedObjects();
 createSkin(myData.skinID);
 createPanels();
}
function initFscommands() {
 fscommand("showmenu", false);
 fscommand("allowscale", false);
}
function initVariables() {
 Root = this;
 isMp3 = true;
 currentPlayID = 0;
 currentReadyID = 0;
 currentReadyID2 = 0;
 currentListID = 0;
 currentListID2 = 0;
 currentListBtnPos = 0;
 currentListBtnPos2 = 0;
 wtime = 10000;
 doubleTime = 1000;
 btnColor = 0x999999;
 btnUnableColor = 0x666666;
 defaultSkin = "http://www.fly-think.com/wei/1.swf";
 rightAlignTf = new TextFormat();
 rightAlignTf.align = "right";
 centerAlignTf = new TextFormat();
 centerAlignTf.size = 10;
 centerAlignTf.font = "Arial";
 centerAlignTf.align = "center";
 sw = Math.round(Stage.width);
 sh = Math.round(Stage.height);
}
function initSharedObjects() {
 james_so = SharedObject.getLocal("james");
 if (!james_so.data.mp3Array) {
  james_so.data.mp3Array = [];
  james_so.data.skinArray = [];
  james_so.data.skinID = 0;
  james_so.data.pan = 0;
  james_so.data.volume = 50;
  james_so.data.isRandom = false;
  james_so.flush();
 }
 myData = james_so.data;
}
//*******************************************************************创建部分*********************************************************//
function createSkin(id) {
 create(this, [["skin", 0]]);
 if (myData.skinArray.length != 0) {
  if (id == -1) {
   this.skin.loadMovie(defaultSkin);
  } else {
   this.skin.loadMovie(myData.skinArray[id][1]);
  }
 } else {
  this.skin.loadMovie(defaultSkin);
 }
 var loop = function (obj) {
  obj._visible = false;
  var loader = obj.getBytesLoaded();
  var total = obj.getBytesTotal();
  if (obj._width>0) {
   clearInterval(interval);
   obj._width = sw;
   obj._height = sh;
   obj._visible = true;
   myData.skinID = id;
   james_so.flush();
   if (!isMp3) {
    resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
   }
  }
 };
 var interval = setInterval(loop, 10, this.skin);
}
function createDefaultSkin() {
 this.skin.loadMovie(defaultSkin);
 var loop = function (obj) {
  obj._visible = false;
  var loader = obj.getBytesLoaded();
  var total = obj.getBytesTotal();
  if (obj._width>0) {
   clearInterval(interval);
   obj._width = sw;
   obj._height = sh;
   obj._visible = true;
   myData.skinID = id;
   james_so.flush();
   if (!isMp3) {
    resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
   }
  }
 };
 var interval = setInterval(loop, 10, this.skin);
}
function createPanels() {
 createSoundInfos();
 createMp3List();
 createOption();
}
//***********************************创建上层面板****************************************************//
function createSoundInfos() {
 create(this, [["info", 2]]);
 createSoundInfosBg();
 createSoundInfosText();
 createSoundInfosPosition();
 createSoundInfosPan();
 createSoundInfosVolum();
 createSoundInfosCtrl();
 showSoundInfo("No Sound", formatTime(obj.position)+"/"+formatTime(obj.duration));
}
function createSoundInfosBg() {
 create(this.info, [["bg", 0]]);
 with (this.info.bg) {
  moveTo(0, 0);
  var colors = [0xffffff, 0xffffff];
  var alphas = [60, 0];
  var ratios = [0, 0xFF];
  var matrix = {matrixType:"box", x:0, y:0, w:sw, h:sh/20, r:Math.PI/2};
  beginGradientFill("linear", colors, alphas, ratios, matrix);
  lineTo(0, sh/4);
  lineTo(sw, sh/4);
  lineTo(sw, 0);
  lineTo(0, 0);
  endFill();
 }
}
function createSoundInfosText() {
 create(this.info, [["txts", 1]]);
 create(this.info.txts, [["bg", 0]]);
 createBg(this.info.txts.bg, 2, 2, sw-4, 20, "0x000000", 80);
 this.info.txts.createTextField("nameTxt", 1, 2, 2, sw-4, 20);
 this.info.txts.createTextField("timeTxt", 2, 2, 2, sw-4, 20);
}
function createSoundInfosPosition() {
 create(this.info, [["position", 2]]);
 this.info.position._y = sh/18+18;
 this.info.position._x = 2;
 create(this.info.position, [["bg", 0], ["bar", 1]]);
 drawFrame(this.info.position, 0, sh/30+6.5, sw-4, 6);
 createBg(this.info.position.bg, 2, sh/30+6.5, sw-8, 2, "0x000000", 100);
 createBtn(this.info.position.bar, 2, sh/30+4.5, 12, 6, btnColor);
 this.info.position.bar.enabled = false;
 this.info.position.bar.setEnabled = function(flag) {
  createBtn(this, 2, sh/30+4.5, 12, 6, flag ? (btnColor) : (btnUnableColor));
  this.enabled = flag;
 };
 activePosition(this.info.position.bar, this.info.position.bg, 0, 0, sw-8-6-4-2, 0, "setSoundPosition");
}
function createSoundInfosPan() {
 create(this.info, [["pan", 3]]);
 this.info.pan._y = sh/18+11;
 this.info.pan._x = sw*13/20-12;
 create(this.info.pan, [["bg", 0], ["bar", 1]]);
 drawFrame(this.info.pan, 0, sh/30+1, sw/8+4, 6);
 createBg(this.info.pan.bg, 2, sh/30+1, sw/8, 2, "0x000000", 100);
 createBtn(this.info.pan.bar, 2, sh/30-0.5, 6, 6, btnColor);
 activeBar(this.info.pan.bar, 0, 0, sw/8-5, 0, "setSoundPan");
 this.info.pan.bar._x = (this.info.pan.bg._width/2)+(this.info.pan.bg._width-this.info.pan.bar._width)*(myData.pan/200)-this.info.pan.bar._width/2;
}
function createSoundInfosVolum() {
 create(this.info, [["volum", 4]]);
 this.info.volum._y = sh/18+11;
 this.info.volum._x = this.info.pan.getBounds(this.info).xMax+2;
 create(this.info.volum, [["bg", 0], ["bar", 1]]);
 drawFrame(this.info.volum, 0, sh/30+1, sw*9/40+4, 6);
 createBg(this.info.volum.bg, 2, sh/30+1, sw*9/40, 2, "0x000000", 100);
 createBtn(this.info.volum.bar, 2, sh/30-0.5, 8, 6, btnColor);
 activeBar(this.info.volum.bar, 0, 0, sw*9/40-6, 0, "setSoundVolume");
 this.info.volum.bar._x = (this.info.volum.bg._width-this.info.volum.bar._width)*(myData.volume/100);
}
function createSoundInfosCtrl() {
 create(this.info, [["ctrl", 5]]);
 this.info.ctrl._y = sh/18+11;
 this.info.ctrl._x = 2;
 create(this.info.ctrl, [["playBtn", 0], ["stopBtn", 1], ["randomBtn", 2], ["listBtn", 3], ["clear", 4]]);
 createTextBtn(this.info.ctrl.playBtn, 2, 2, 15, 12, btnColor, ">");
 createTextBtn(this.info.ctrl.stopBtn, 19, 2, 15, 12, btnColor, "□");
 createTextClickBtn(this.info.ctrl.randomBtn, 36, 2, 15, 12, btnColor, "R", "T");
 createListChangeBtn(this.info.ctrl.listBtn, 53, 2, 30, 12, btnColor, "Skin", "Mp3", "changeList");
 createTextBtn(this.info.ctrl.clear, 85, 2, 15, 12, btnColor, "C");
 this.info.ctrl.clear.onRelease = function() {
  alert("Delete all from list?", "deleteAll");
 };
 setPlayBtn();
}
function deleteAll() {
 if (isMp3) {
  myData.mp3Array = [];
  james_so.flush();
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
  createMp3ListBtn(myData.mp3Array);
 } else {
  myData.skinArray = [];
  james_so.flush();
  resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
  createMp3ListBtn(myData.skinArray);
  createDefaultSkin();
 }
 closePanel();
}
//************************************创建列表面板*******************************************************//
function createMp3List() {
 create(this, [["list", 1]]);
 this.list._y = sh/4;
 createMp3ListBg();
 createMp3ListList(myData.mp3Array);
 createMp3ListBtn(myData.mp3Array);
}
function drawFrame(mc, x, y, w, h) {
 with (mc) {
  moveTo(x, y-h);
  lineStyle(x, "0x000000", 20);
  lineTo(x+w, y-h);
  lineTo(x+w, y+h);
  lineTo(x, y+h);
  lineTo(x, y-h);
 }
}
function createMp3ListBg() {
 create(this.list, [["bg", 0]]);
 with (this.list.bg) {
  moveTo(0, 0);
  var colors = [0x000000, 0x000000];
  var alphas = [100, 45];
  var ratios = [0, 0xFF];
  var matrix = {matrixType:"box", x:0, y:0, w:sw, h:sh/20, r:Math.PI/2};
  beginGradientFill("linear", colors, alphas, ratios, matrix);
  lineTo(sw, 0);
  lineTo(sw, sh*2/3);
  lineTo(0, sh*2/3);
  lineTo(0, 0);
  endFill();
 }
}
function createMp3ListList(array) {
 create(this.list, [["list", 1]]);
 this.list.list._x = 0;
 this.list.list._y = sw/25;
 resetMp3List(array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
}
function eleClass(mc, y, id, long, name) {
 mc._y = y;
 mc.id = id;
 createListEle(mc, long, 18, name);
 mc.selected = function(flag) {
  createListBg(this, 0, 0, long, 18, 0x000000, (flag ? 80 : 0));
 };
 mc.played = function(flag) {
  this.txt.textColor = flag ? "0xffff00" : "0xcccccc";
 };
}
function resetMp3List(array, ID, playID, readyID, event) {
 createListChangeBtn(this.info.ctrl.listBtn, 53, 2, 30, 12, btnColor, "Skin", "Mp3", "changeList");
 for (var i = 0; i<6; i++) {
  this.list.list["ele"+i].removeMovieClip();
 }
 var long = sw*2/3;
 var len = Math.min(6, array.length-ID);
 for (var i = 0, j = ID; i<len; i++, j++) {
  create(this.list.list, [["ele"+i, i]]);
  eleClass(this.list.list["ele"+i], i*20, j, long, array[j][0]);
 }
 var oldTime, selnew, selold;
 delete this.list.list.onMouseDown;
 this.list.list.onMouseDown = function() {
  if (!panelFlag) {
   if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
    oldTime = (oldTime == undefined) ? getTimer() : oldTime;
    for (var i = 0; i<len; i++) {
     if (this["ele"+i].hitTest(_root._xmouse, _root._ymouse, true)) {
      this["ele"+i].selected(true);
      set(readyID, this["ele"+i].id);
      selnew = this["ele"+i];
     } else {
      this["ele"+i].selected(false);
     }
    }
    if (getTimer()-oldTime<doubleTime) {
     if (selnew == selold) {
      eval(event)(selnew.id);
     } else {
      selold = selnew;
      oldTime = getTimer();
     }
    } else {
     selold = selnew;
     oldTime = getTimer();
    }
   }
  }
 };
 setListState(eval(playID), eval(readyID));
}
function setListState(playID, readyID) {
 for (var i = 0; i<6; i++) {
  if (this.list.list["ele"+i] != undefined) {
   if (this.list.list["ele"+i].id == playID) {
    this.list.list["ele"+i].played(true);
   }
   if (this.list.list["ele"+i].id == readyID) {
    this.list.list["ele"+i].selected(true);
   }
  } else {
   return;
  }
 }
}
function createMp3ListBtn(array) {
 if (array.length<=6) {
  this.list.ctrl.removeMovieClip();
 } else {
  var long = (6/array.length)*(sh*2/3-2);
  create(this.list, [["ctrl", 2]]);
  create(this.list.ctrl, [["bg", 0], ["bar", 1]]);
  createBg(this.list.ctrl.bg, sw*19/20, 2, sw/40, sh*2/3-2, "0x000000", 100);
  createBtn(this.list.ctrl.bar, sw*19/20-0.5, 2, sw/40+1, long, btnColor);
  this.list.ctrl.bar._y = (isMp3) ? (currentListBtnPos) : (currentListBtnPos2);
  activeBar(this.list.ctrl.bar, 0, 0, 0, sh*2/3-2-long, "alignList", [array]);
 }
}
function createListEle(mc, w, h, msg) {
 mc.createTextField("txt", 0, 10, 0, w, h);
 createListBg(mc, 0, 0, w, h, 0x000000, 0);
 setText(mc.txt, getShort(msg, 8));
 if (AriaTf == undefined) {
  AriaTf = new TextFormat();
  AriaTf.font = "Arial";
 }
 mc.txt.setTextFormat(AriaTf);
}
function createListBg(mc, x, y, w, h, color, alpha) {
 with (mc) {
  clear();
  moveTo(0, 0);
  var colors = [color, color];
  var alphas = [alpha, 0];
  var ratios = [0, 0xFF];
  var matrix = {matrixType:"box", x:x/2, y:y/2, w:w, h:h, r:0};
  beginGradientFill("linear", colors, alphas, ratios, matrix);
  lineTo(w, 0);
  lineTo(w, h);
  lineTo(0, h);
  lineTo(0, 0);
  endFill();
 }
}
//***************************************创建下层面板********************************************************//
function createOption() {
 create(this, [["option", 3]]);
 this.option._y = sh*11/12;
 createOptionBg();
 createOptionBtns();
}
function createOptionBg() {
 create(this.option, [["bg", 0]]);
 with (this.option.bg) {
  moveTo(0, 0);
  var colors = [0xffffff, 0x000000];
  var alphas = [30, 0];
  var ratios = [0, 0xFF];
  var matrix = {matrixType:"box", x:0, y:0, w:sw, h:sh/12, r:Math.PI/2};
  beginGradientFill("linear", colors, alphas, ratios, matrix);
  lineTo(sw, 0);
  lineTo(sw, sh/12);
  lineTo(0, sh/12);
  lineTo(0, 0);
  endFill();
 }
}
function createOptionBtns() {
 create(this.option, [["adds", 1], ["del", 2], ["info", 3], ["saves", 5], ["loads", 6], ["about", 7]]);
 createTextBtn(this.option.adds, 2, 2, sw/8, sw/12-4, btnColor, "Add");
 createTextBtn(this.option.del, this.option.adds.getBounds(this.option).xMax+2, 2, sw/8, sw/12-4, btnColor, "Del");
 createTextBtn(this.option.info, this.option.del.getBounds(this.option).xMax+2, 2, sw/8+4, sw/12-4, btnColor, "Info");
 createTextBtn(this.option.saves, this.option.info.getBounds(this.option).xMax+7, 2, sw/8+4, sw/12-4, btnColor, "Save");
 createTextBtn(this.option.loads, this.option.saves.getBounds(this.option).xMax+2, 2, sw/8+4, sw/12-4, btnColor, "Load");
 createTextBtn(this.option.about, this.option.loads.getBounds(this.option).xMax+7, 2, sw/8+12, sw/12-4, btnColor, "About");
 this.option.adds.onRelease = function() {
  showAddPanel();
 };
 this.option.del.onRelease = function() {
  showDelPanel();
 };
 this.option.info.onRelease = function() {
  showInfoPanel();
 };
 this.option.saves.onRelease = function() {
  showSaveAndLoadPanel("Save");
 };
 this.option.loads.onRelease = function() {
  showSaveAndLoadPanel("Load");
 };
 this.option.about.onRelease = function() {
  showAboutPanel();
 };
}
//****************************************辅助函数*******************************************************//
function setText(txt, msg, tf) {
 txt.selectable = false;
 txt.textColor = "0xcccccc";
 txt.text = msg;
 txt.setTextFormat(tf);
}
function formatTime(misec) {
 var tempsec = Math.floor(misec/1000);
 var sec = tempsec%60;
 var min = Math.floor(tempsec/60);
 return format(min, 1)+":"+format(sec, 2);
}
function format(str, num) {
 var s = String(str);
 for (var i = s.length; i<num; i++) {
  s = "0"+s;
 }
 return s;
}
function formatInputText(txt) {
 txt.oldText = txt.text;
 txt.onChanged = function() {
  if (this.text == this.oldText+" ") {
   this.text = this.oldText;
  }
  this.oldText = this.text;
 };
}
function formatURL(urls) {
 var str = "";
 for (var i = 0; i<urls.length; i++) {
  if (urls.charAt(i) != "\\") {
   str = str+urls.charAt(i);
  } else {
   str = str+"/";
  }
 }
 return str;
}
function unformatURL(urls) {
 var str = "";
 for (var i = 0; i<urls.length; i++) {
  if (urls.charAt(i) != "/") {
   str = str+urls.charAt(i);
  } else {
   str = str+"\\";
  }
 }
 return str;
}
//*****************************************动作函数******************************************************//
function selectSound(id) {
 delete this.info.position.bg.onEnterFrame;
 stopAllSounds();
 mySound.stop();
 mySound.attachSound(null);
 delete mySound;
 mySound = new Sound();
 var url = myData.mp3Array[id][1];
 if (url.substr(0, 4) != "http") {
  mySound.loadSound(url);
  showSoundInfo("Loading...", formatTime(0)+"/"+formatTime(0));
  streamLoad = false;
  var stime = getTimer();
  var loop = function () {
   if (mySound.getBytesTotal() == undefined) {
    if (getTimer()-stime>wtime) {
     showSoundInfo("File not found!", formatTime(0)+"/"+formatTime(0));
     if (getTimer()-stime-wtime>1000) {
      stopAllSounds();
      clearInterval(interval);
      asSoundComplete();
     }
    }
   }
   var l = mySound.getBytesLoaded();
   var t = mySound.getBytesTotal();
   if (l == t && l>0 && t>10) {
    clearInterval(interval);
    currentPlayID = id;
    mySound.start();
    asSoundLoaded(mySound);
   }
  };
  var interval = setInterval(loop, 10);
 } else {
  mySound.loadSound(url, true);
  streamLoad = true;
  currentPlayID = id;
  asSoundLoaded(mySound);
 }
}
function asSoundLoaded(sounds) {
 sounds.setPan(myData.pan);
 sounds.setVolume(myData.volume);
 startPosition(sounds);
 if (isMp3) {
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
 }
 sounds.onSoundComplete = function() {
  asSoundComplete();
 };
}
function getNextSound() {
 return (myData.isRandom) ? (random(myData.mp3Array.length)) : ((currentPlayID == myData.mp3Array.length-1) ? (0) : (currentPlayID+1));
}
function asSoundComplete() {
 var path = this.list.list;
 currentPlayID = getNextSound();
 if (isMp3) {
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
 }
 selectSound(currentPlayID);
}
//*******************声音导向控制***************************//
function startPosition(obj) {
 var name = ((streamLoad) ? ("(Net)") : (""))+myData.mp3Array[currentPlayID][0];
 this.info.position.bar.setEnabled(!streamLoad);
 createTextBtn(this.info.ctrl.playBtn, 2, 2, 15, 12, (!streamLoad) ? (btnColor) : (btnUnableColor), "||");
 this.info.ctrl.playBtn.enabled = !streamLoad;
 var stime = getTimer();
 this.info.position.bg.onEnterFrame = function() {
  var rate = 0;
  if (!streamLoad) {
   rate = obj.position/obj.duration;
   showSoundInfo(name, formatTime(obj.position)+"/"+formatTime(obj.duration));
  } else {
   var str;
   var dur;
   if (obj.duration) {
    dur = (obj.duration*obj.getBytesTotal()/obj.getBytesLoaded());
    rate = obj.position/dur;
    if (formatTime(obj.position) == formatTime(obj.duration)) {
     str = "Buffering...";
    } else {
     str = name;
    }
   } else {
    str = "Connecting...";
    if (getTimer()-stime>wtime) {
     mySound.stop();
     str = "Disconnect!";
     if (getTimer()-stime-wtime>2000) {
      delete this.onEnterFrame;
      asSoundComplete();
      return;
     }
    }
   }
   showSoundInfo(str, formatTime(obj.position)+"/"+formatTime(dur));
  }
  this._parent.bar._x = rate*(this._width-this._parent.bar._width);
 };
}
function stopPosition(obj) {
 this.info.position.bar.enabled = false;
 this.info.ctrl.playBtn.enabled = true;
 createTextBtn(this.info.ctrl.playBtn, 2, 2, 15, 12, (btnColor), ">");
 stopAllSounds();
 mySound.stop();
 mySound.attachSound(null);
 delete mySound;
 showSoundInfo("No Sound", formatTime(obj.position)+"/"+formatTime(obj.duration));
 this.info.position.bar._x = 0;
 delete this.info.position.bg.onEnterFrame;
}
function pausePosition(obj) {
 this.info.ctrl.playBtn.txt.text = ">";
 this.info.ctrl.playBtn.txt.setTextFormat(centerAlignTf);
 mySound.stop();
 savePos = mySound.position/1000;
 delete this.info.position.bg.onEnterFrame;
}
function activePosition(bar, bg, l, t, r, b, event) {
 bar.useHandCursor = false;
 bar.onPress = function() {
  delete bg.onEnterFrame;
  this.startDrag(0, l, t, r, b);
 };
 bar.onRelease = bar.onReleaseOutside=function () {
  stopDrag();
  var rate = (bar._x/(bg._width-bar._width));
  eval(event).apply(Root, [rate]);
 };
}
function setSoundPosition(rate) {
 mySound.stop();
 if (rate<1) {
  mySound.start(rate*mySound.duration/1000);
  startPosition(mySound);
 } else {
  asSoundComplete();
 }
}
//********************声音均衡**************************//
function setSoundPan() {
 var path = this.info.pan;
 var dot = (path.bar._x+path.bar._width/2);
 var center = path.bg._width/2;
 var total = path.bg._width-path.bar._width;
 var rate = (dot-center)/total;
 mySound.setPan(rate*200);
 myData.pan = rate*200;
 james_so.flush();
}
//*******************音量*************************//
function setSoundVolume() {
 var path = this.info.volum;
 var dot = (path.bar._x);
 var total = path.bg._width;
 var rate = (dot/total);
 mySound.setVolume(rate*100);
 myData.volume = rate*100;
 james_so.flush();
}
//***************显示歌曲文本*****************************//
function showSoundInfo(name, time) {
 setText(this.info.txts.nameTxt, getShort(name, 14));
 setText(this.info.txts.timeTxt, time, rightAlignTf);
}
function getShort(str, len) {
 if (str.length>len) {
  return str.substr(0, len-1)+"...";
 } else {
  return str;
 }
}
//*******************定义按钮**************************//
function setPlayBtn() {
 this.info.ctrl.playBtn.onRelease = function() {
  if (this.txt.text == ">") {
   if (myData.mp3Array.length == 0) {
   } else {
    if (mySound == undefined) {
     selectSound(currentPlayID);
    } else {
     mySound.start(savePos);
     startPosition(mySound);
    }
   }
  } else {
   pausePosition();
  }
 };
 this.info.ctrl.stopBtn.onRelease = function() {
  stopPosition();
 };
}
//***************************************激活按钮与定义按钮******************************************************//
function activeBar(bar, l, t, r, b, event, arg) {
 bar.useHandCursor = false;
 bar.onPress = function() {
  this.startDrag(0, l, t, r, b);
 };
 bar.onRelease = bar.onReleaseOutside=function () {
  stopDrag();
  eval(event).apply(Root, arg);
 };
}
function alignList(array) {
 var long = this.list.ctrl.bar._y-this.list.ctrl.bg._y;
 var total = this.list.ctrl.bg._height-this.list.ctrl.bar._height;
 var id = Math.round((long/total)*(array.length-6));
 if (isMp3) {
  currentListID = id;
  resetMp3List(array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
  currentListBtnPos = this.list.ctrl.bar._y;
 } else {
  currentListID2 = id;
  resetMp3List(array, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
  currentListBtnPos2 = this.list.ctrl.bar._y;
 }
}
function createBg(mc, x, y, w, h, c, a) {
 with (mc) {
  clear();
  moveTo(x, y);
  beginFill(c, a);
  lineTo(x+w, y);
  lineTo(x+w, y+h);
  lineTo(x, y+h);
  lineTo(x, y);
  endFill();
 }
}
function createBtn(mc, x, y, w, h, color) {
 with (mc) {
  moveTo(x, y);
  var colors = [0xcccccc, color];
  var alphas = [100, 100];
  var ratios = [0, 0xff];
  var matrix = {matrixType:"box", x:x, y:y, w:w/2, h:h/4, r:Math.PI/2};
  beginGradientFill("linear", colors, alphas, ratios, matrix);
  lineStyle(0, "0xffffff", 80);
  lineTo(x+w, y);
  lineStyle(0, "0x000000", 80);
  lineTo(x+w, y+h);
  lineStyle(0, "0x000000", 100);
  lineTo(x, y+h);
  lineStyle(0, "0xffffff", 50);
  lineTo(x, y);
  endFill();
 }
}
function createTextBtn(mc, x, y, w, h, color, msg) {
 createBtn(mc, x, y, w, h, color);
 mc.createTextField("txt", 0, x, y-2, w, h+4);
 mc.txt.selectable = false;
 mc.txt.text = msg;
 mc.txt.textColor = "0x000000";
 mc.txt.setTextFormat(centerAlignTf);
 mc.useHandCursor = false;
}
function createTextClickBtn(mc, x, y, w, h, color, msg1, msg2) {
 createTextBtn(mc, x, y, w, h, color, myData.isRandom ? (msg1) : (msg2));
 mc.onRelease = function() {
  myData.isRandom = !myData.isRandom;
  james_so.flush();
  createTextClickBtn(mc, x, y, w, h, color, msg1, msg2, flag);
 };
}
function createListChangeBtn(mc, x, y, w, h, color, msg1, msg2, event) {
 createTextBtn(mc, x, y, w, h, color, isMp3 ? (msg1) : (msg2));
 mc.onRelease = function() {
  isMp3 = !isMp3;
  eval(event)();
  createListChangeBtn(mc, x, y, w, h, color, msg1, msg2, event);
 };
}
function changeList() {
 if (isMp3) {
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
  createMp3ListBtn(myData.mp3Array);
 } else {
  resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
  createMp3ListBtn(myData.skinArray);
 }
}
//******************************************************************面板部分********************************************************//
function showPanelBg() {
 panelFlag = true;
 create(this, [["panel", 10]]);
 create(this.panel, [["hit", 0], ["bg", 1], ["closeBtn", 2], ["panel", 3], ["okBtn", 4]]);
 createBg(this.panel.hit, 0, 0, sw, sh-20, "0x000000", 0);
 createBg(this.panel.bg, 0, this.list._y, sw, sh*2/3, "0x000000", 80);
 this.panel.hit.onRelease = null;
 this.panel.hit.useHandCursor = false;
 createTextBtn(this.panel.closeBtn, sw*7/8-6, this.list._y+sh*2/3-sw/12+4, sw/8+6, sw/12-4, btnColor, "Close");
 createTextBtn(this.panel.okBtn, sw*7/8-6-2-sw/8-6, this.list._y+sh*2/3-sw/12+4, sw/8+6, sw/12-4, btnColor, "Ok");
 this.panel.closeBtn.onRelease = function() {
  closePanel();
 };
}
function showAddPanel() {
 showPanelBg();
 showTexts();
 if (!isMp3) {
  create(this.panel, [["def", 10]]);
  createTextBtn(this.panel.def, this.panel.okBtn.getBounds(this.panel).xMin-52, this.list._y+sh*2/3-sw/12+4, 50, sw/12-4, btnColor, "Default");
  this.panel.def.onRelease = function() {
   myData.skinID = -1;
   james_so.flush();
   createSkin(myData.skinID);
   closePanel();
  };
 }
 this.panel.okBtn.onRelease = function() {
  if (this._parent.panel.title_input.text != "" && this._parent.panel.url_input.text != "") {
   if (isMp3) {
    myData.mp3Array.push([this._parent.panel.title_input.text, formatURL(this._parent.panel.url_input.text)]);
    james_so.flush();
    resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
    createMp3ListBtn(myData.mp3Array);
   } else {
    myData.skinArray.push([this._parent.panel.title_input.text, formatURL(this._parent.panel.url_input.text)]);
    james_so.flush();
    if (myData.skinArray.length == 1) {
     createSkin(0);
    } else {
     resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
    }
    createMp3ListBtn(myData.skinArray);
   }
   closePanel();
  }
 };
}
function showDelPanel() {
 if (this.panel == undefined) {
  alert("Delete "+(isMp3 ? myData.mp3Array[currentReadyID][0] : myData.skinArray[currentReadyID2][0])+" ?", "deleteReady");
 }
}
function deleteReady() {
 if (isMp3) {
  if (currentReadyID<currentPlayID) {
   currentPlayID--;
  }
  myData.mp3Array.splice(currentReadyID, 1);
  currentReadyID--;
  james_so.flush();
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
  createMp3ListBtn(myData.mp3Array);
 } else {
  if (currentReadyID2<myData.skinID) {
   myData.skinID--;
  }
  myData.skinArray.splice(currentReadyID2, 1);
  currentReadyID2--;
  james_so.flush();
  resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
  createMp3ListBtn(myData.skinArray);
 }
 closePanel();
}
function showInfoPanel() {
 if (currentReadyID != undefined) {
  showPanelBg();
  showTexts();
  this.panel.panel.title_input.text = isMp3 ? (myData.mp3Array[currentReadyID][0]) : (myData.skinArray[currentReadyID2][0]);
  this.panel.panel.url_input.text = isMp3 ? (myData.mp3Array[currentReadyID][1]) : (myData.skinArray[currentReadyID2][1]);
  this.panel.okBtn.onRelease = function() {
   if (this._parent.panel.title_input.text != "" && this._parent.panel.url_input.text != "") {
    if (isMp3) {
     myData.mp3Array[currentReadyID] = ([this._parent.panel.title_input.text, formatURL(this._parent.panel.url_input.text)]);
     james_so.flush();
     resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
     createMp3ListBtn(myData.mp3Array);
    } else {
     myData.skinArray[currentReadyID2] = ([this._parent.panel.title_input.text, formatURL(this._parent.panel.url_input.text)]);
     james_so.flush();
     resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
     createMp3ListBtn(myData.skinArray);
    }
    closePanel();
   }
  };
 }
}
function showTexts() {
 this.panel.panel.createTextField("title", 0, 2, this.list._y+2, 80, 20);
 this.panel.panel.createTextField("url", 1, 2, this.list._y+2+sh/5, 80, 20);
 this.panel.panel.createTextField("title_input", 2, 12, this.list._y+2+22, sw-24, 20);
 this.panel.panel.createTextField("url_input", 3, 12, this.list._y+2+sh/5+22, sw-24, 50);
 setText(this.panel.panel.title, (isMp3) ? ("Sound title:") : ("Skin title"));
 setText(this.panel.panel.url, (isMp3) ? ("Sound URL:") : ("Skin URL"));
 this.panel.panel.title_input.border = true;
 this.panel.panel.title_input.borderColor = "0x666666";
 this.panel.panel.title_input.textColor = "0xcccccc";
 this.panel.panel.title_input.type = "input";
 this.panel.panel.url_input.border = true;
 this.panel.panel.url_input.borderColor = "0x666666";
 this.panel.panel.url_input.textColor = "0xcccccc";
 this.panel.panel.url_input.type = "input";
 formatInputText(this.panel.panel.title_input);
 formatInputText(this.panel.panel.url_input);
 this.panel.panel.url_input.wordWrap = true;
}
function showSaveAndLoadPanel(msg) {
 showPanelBg();
 showSaveAndLoadTexts(msg);
}
function showSaveAndLoadTexts(msg) {
 var path = this.panel.panel;
 path.createTextField("title", 0, 2, this.list._y+2, sw, 20);
 path.createTextField("urls", 1, 12, this.list._y+22, sw-24, 20);
 path.createTextField("frontname", 2, 12, this.list._y+42, 50, 20);
 path.createTextField("filename", 3, 62, this.list._y+42, sw/2, 20);
 path.createTextField("backname", 4, sw/2+62, this.list._y+42, 40, 20);
 path.title.textColor = path.urls.textColor=path.frontname.textColor=path.filename.textColor=path.backname.textColor="0xcccccc";
 path.title.text = msg+" "+(isMp3 ? ("Mp3") : ("Skin"))+" "+"list";
 path.urls.html = true;
 //path.urls.htmlText = getLocalURL();
 path.filename.border = true;
 path.filename.borderColor = "0xcccccc";
 path.filename.type = "input";
 formatInputText(path.filename);
 path.frontname.text = ((isMp3) ? ("mp3list") : ("skinlist"))+"_";
 path.backname.text = ".sol";
 this.panel.okBtn.onRelease = function() {
  eval("start"+msg+"File")(path.filename.text);
 };
}
function startSaveFile(msg) {
 save_so = SharedObject.getLocal("save/"+(isMp3 ? ("mp3list_") : ("skinlist_"))+msg);
 if (save_so.data.array == undefined) {
  doSave();
 } else {
  alert("File exist,replace it?", "doSave");
 }
}
function startLoadFile(msg) {
 load_so = SharedObject.getLocal("save/"+(isMp3 ? ("mp3list_") : ("skinlist_"))+msg);
 if (load_so.data.array == undefined) {
  alert("File does not exist!", "closePanel");
 } else {
  alert("Once loaded,the current list will be replaced,continue?", "doLoad");
 }
}
function doLoad() {
 if (isMp3) {
  myData.mp3Array = new Array();
  for (var i = 0; i<load_so.data.array.length; i++) {
   myData.mp3Array.push(load_so.data.array[i]);
  }
  james_so.flush();
  resetMp3List(myData.mp3Array, currentListID, "currentPlayID", "currentReadyID", "selectSound");
  createMp3ListBtn(myData.mp3Array);
 } else {
  myData.skinArray = new Array();
  for (var i = 0; i<load_so.data.array.length; i++) {
   myData.skinArray.push(load_so.data.array[i]);
  }
  james_so.flush();
  resetMp3List(myData.skinArray, currentListID2, "myData.skinID", "currentReadyID2", "createSkin");
  createMp3ListBtn(myData.skinArray);
 }
 closePanel();
}
function doSave() {
 var arrays = isMp3 ? (myData.mp3Array) : (myData.skinArray);
 save_so.data.array = new Array();
 for (var i = 0; i<arrays.length; i++) {
  save_so.data.array.push(arrays[i]);
 }
 save_so.flush();
 closePanel();
}
function alert(msg, func) {
 showPanelBg();
 this.panel.panel.createTextField("title", 0, 2, this.list._y+2, sw, sh/2);
 this.panel.panel.title.textColor = "0xcccccc";
 this.panel.panel.title.wordWrap = true;
 this.panel.panel.title.text = msg;
 this.panel.okBtn.onRelease = function() {
  eval(func)();
 };
}
function getLocalURL() {
 var os = System.capabilities.os;
 var path;
 if (os == "Windows 98/ME") {
  path = "<font color='#cccccc'>c:/Application Data/Macromedia/Flash Player/localhost/"+getSwfURL()+"#save/</font>";
 } else {
  path = "<font color='#cccccc'>c:/Documents and Settings/</font>"+"<font color='#ff0000'>YOUR NAME</font>"+"<font color='#cccccc'>/Application Data/Macromedia/Flash Player/localhost/"+getSwfURL()+"#save/</font>";
 }
 return unFormatURL(path);
}
function getSwfURL() {
 var arr = _root._url.split("/");
 var swfPath;
 for (var i = 4; i<arr.length; i++) {
  swfPath = swfPath+arr[i]+"/";
 }
 return unescape(swfPath);
}
function showAboutPanel() {
 showPanelBg();
 this.panel.okBtn._visible = false;
 this.panel.panel.createTextField("title", 0, 2, this.list._y+2, sw, 150);
 this.panel.panel.title.textColor = "0xcccccc";
 this.panel.panel.title.wordWrap = true;
 this.panel.panel.title.selectable = false;
 this.panel.panel.title.text = "Flash Mp3 Player 3.0"+"\n"+"\n"+"James.li"+"\n"+"QQ:18668798"+"\n"+"okey@xinhuanet.com"+"\n"+"2004-7-18"+"\n"+"\n"+"Special Thanks: Green Tea";
}
function closePanel() {
 panelFlag = false;
 this.panel.removeMovieClip();
}
function create(mc, array) {
 for (var i = 0; i<array.length; i++) {
  mc.createEmptyMovieClip(array[i][0], array[i][1]);
 }
}

posted on 2006-08-01 11:56  榻榻米  阅读(1283)  评论(3编辑  收藏  举报