本主題承接以下主題_有不同的跳播輪播機制
[AS2] 自動輪播+按鈕操控跳播_從跳播處繼續輪播
http://terfict.blogspot.com/2009/12/as2-swf-6num1mc-num6mc-containermc-swf.html
*主場景設置6個影片按鈕實體,依序分別為num1_mc ~ num6_mc
*另設置一個container_mc實體, 作為載入外部SWF的容器.
SWF預覽
http://sites.google.com/site/terfict3/home/981103_as2_alternate_2.swf
第一影格AS2
//
var j:Number = 1; //宣告j變數
var intervalID:Number; //宣告計時器變數
var sec:Number = 3; //設定每幾秒更替內容
var keyNum:Number = 0; //
//
//以陣列設定外部swf檔名,有幾個就設定幾個,可以試著隱藏幾個來預覽看看
var fileName:Array = new Array();
fileName[1] = "981103_as2_alternate_1a.swf";
fileName[2] = "981103_as2_alternate_1b.swf";
fileName[3] = "981103_as2_alternate_1c.swf";
fileName[4] = "981103_as2_alternate_1d.swf";
fileName[5] = "981103_as2_alternate_1e.swf";
fileName[6] = "981103_as2_alternate_1f.swf";
//按下按鈕的事件處理
for (var i:Number = 1; i
var myBtn:MovieClip = new MovieClip();
myBtn = eval("num"+i+"_mc");
myBtn.flag = i;
//
myBtn.onRelease = function() {
keyNum = j;
trace(j);
clearInterval(intervalID);
upStatus();
container_mc.loadMovie(fileName[this.flag]);
this.gotoAndStop("playing");
j = this.flag;
checkNum();
timekeeper();
this.enabled=false;
};
}
//載入第一個swf
container_mc.loadMovie(fileName[j]);
num1_mc.gotoAndStop("_down");
this["num"+j+"_mc"].enabled=false;
j++;
//計時器,
function timekeeper() {
intervalID = setInterval(this, "alternateSwf", 1000*sec);
}
//呼叫timekeeper()函式,即呼叫計時器
timekeeper();
//輪流載入外部swf
function alternateSwf() {
upStatus();
container_mc.loadMovie(fileName[j]);
this["num"+j+"_mc"].gotoAndStop("_down");
this["num"+j+"_mc"].enabled=false;
checkNum();
}
//所有影片按鈕狀態跳至其本身的_up影格
function upStatus() {
for (var i:Number = 1; i
this["num"+i+"_mc"].gotoAndStop("_up");
this["num"+i+"_mc"].enabled=true;
}
}
//
function checkNum() {
if (j
if(keyNum!=0){
j=keyNum;
keyNum=0;
}else{
j++;
}
} else {
j = 1;
}
}
FLA下載
沒有留言:
張貼留言