| //Tween、easingクラスのインポート
import mx.transitions.Tween;
import mx.transitions.easing.*;
//表題
var title = "Photo Gallery";
//シリーズ名
var subMenu = [" Orchid", " X'mas Rose", " Bonsai"];
//シリーズごとのスライド数
var slideNum = [49, 28, 26];
//変数の初期値
var num = slideNum[0];//スライド枚数
var serNo = 0;//シリーズ番号
var picNo = 1;//写真番号
//サムネイルの幅、高さ
var tw = 70;
var th = 52.5;
//サムネイル整列列数
var col = 10;
//文字のフォーマット
txtFormat1 = new TextFormat();
txtFormat1.color = 0xFFFFFF;
txtFormat1.size = 16;
txtFormat2 = new TextFormat();
txtFormat2.color = 0xFFFFFF;
txtFormat2.size = 13;
txtFormat3 = new TextFormat();
txtFormat3.color = 0xffc6b1;
txtFormat4 = new TextFormat();
txtFormat4.color = 0xff0000;
//題名表示
this.createTextField("titleTxt",0,10,10,200,50);
titleTxt.text = title;
titleTxt.setTextFormat(txtFormat1);
//サブメニュー(ギャラリーのシリーズ名)の表示用テキストフィールドの配置
this.createEmptyMovieClip("submenuBar",this.getNextHighestDepth());
submenuBar._x = 200;
submenuBar._y = 15;
//サムネイル群収納用ムービークリップの作成と表示
this.createEmptyMovieClip("thumbnailContainer",this.getNextHighestDepth());
thC_w = (tw+0)*col;
thC_h = (th+7)*7;
loadThumb(serNo);
//拡大写真読み込み用ムービークリップ
this.createEmptyMovieClip("load_mc",this.getNextHighestDepth());
//ボタン類収納ムービークリップ
this.createEmptyMovieClip("buttons_mc",200);
var buttons_mc_w = 500;
//送りボタンの表示とロールオーバー効果
forward_btn = buttons_mc.createEmptyMovieClip("f_btn", 201);
forward_btn._x = 280;
forward_btn.createTextField("tf",201,0,0,100,50);
forward_btn.tf.text = " Forward >>";
forward_btn.tf.setTextFormat(txtFormat2);
fillRec(forward_btn,0x444444,110,20);
forward_btn.onRollOver = function() {
forward_btn.tf.setTextFormat(txtFormat3);
fillRec(this,0x000000,110,20);
};
forward_btn.onRollOut = function() {
forward_btn.tf.setTextFormat(txtFormat2);
fillRec(this,0x444444,110,20);
};
//戻りボタンの表示とロールオーバー効果
backward_btn = buttons_mc.createEmptyMovieClip("b_btn", 202);
backward_btn._x = 40;
backward_btn.createTextField("tf",202,0,0,100,50);
backward_btn.tf.text = " << Backward ";
backward_btn.tf.setTextFormat(txtFormat2);
fillRec(backward_btn,0x444444,110,20);
backward_btn.onRollOver = function() {
backward_btn.tf.setTextFormat(txtFormat3);
fillRec(this,0x000,110,20);
};
backward_btn.onRollOut = function() {
backward_btn.tf.setTextFormat(txtFormat2);
fillRec(this,0x444444,110,20);
};
//スライドショウボタン
play_btn = buttons_mc.createEmptyMovieClip("p_btn", 203);
play_btn._x = 150;
play_btn.createTextField("tf",203,0,0,130,50);
play_btn.tf.text = " Slide Show >>PLAY";
play_btn.tf.setTextFormat(txtFormat2);
fillRec(play_btn,0x444444,130,20);
play_btn.onRollOver = function() {
play_btn.tf.setTextFormat(txtFormat3);
fillRec(this,0x000,130,20);
};
play_btn.onRollOut = function() {
play_btn.tf.setTextFormat(txtFormat2);
fillRec(this,0x444444,130,20);
};
stop_btn = buttons_mc.createEmptyMovieClip("s_btn", 204);
stop_btn._x = 150;
stop_btn.createTextField("tf",204,0,0,150,50);
stop_btn.tf.text = " Slide Show □ STOP";
stop_btn.tf.setTextFormat(txtFormat4);
stop_btn._visible = false;
stop_btn.onRollOver = function() {
stop_btn.tf.setTextFormat(txtFormat3);
};
stop_btn.onRollOut = function() {
stop_btn.tf.setTextFormat(txtFormat4);
};
//フルスクリーンボタンの設置と設定
fullscreen_btn = buttons_mc.createEmptyMovieClip("full_btn", this.getNextHighestDepth());
fullscreen_btn._x = 380;
fullscreen_btn.createTextField("tf",this.getNextHighestDepth(),0,0,100,30);
fullscreen_btn.tf.text = " FULLSCREEN";
fullscreen_btn.tf.setTextFormat(txtFormat2);
fillRec(fullscreen_btn,0x444444,110,20);
fullscreen_btn.onRollOver = function() {
fullscreen_btn.tf.setTextFormat(txtFormat3);
fillRec(this,0x000,110,20);
};
fullscreen_btn.onRollOut = function() {
fullscreen_btn.tf.setTextFormat(txtFormat2);
fillRec(this,0x444444,110,20);
};
fullscreen_btn.onRelease = function() {
Stage["displayState"] = "fullScreen";
};
//ウインドウサイズに応じた配置
Stage.scaleMode = "noScale";
Stage.align = "LT";
function setPosition() {
thumbnailContainer._x = Stage.width/2-thC_w/2;
thumbnailContainer._y = Stage.height/2-thC_h/2;
load_mc._x = Stage.width/2-load_mc_w;
load_mc._y = Stage.height/2-load_mc_h;
buttons_mc._x = (Stage.width/2-buttons_mc_w/2);
buttons_mc._y = Stage.height-30;
selectedSubmenu._y = Stage.height-80;
}
myListener = new Object();
myListener.onResize = function() {
setPosition();
};
Stage.addListener(myListener);
setPosition();
//サブメニュー(シリーズ名)の表示と、イベントアクション
for (i=0; i<subMenu.length; i++) {
menuB = submenuBar.createEmptyMovieClip("submenuItem"+i, 100+i);
menuB._x = 100*i;
menuTxt = menuB.createTextField("tf", 100+i, 0, 0, 120, 20);
menuB.tf.text = subMenu[i];
menuB.tf.setTextFormat(txtFormat2);
fillRec(menuB,0x444444,100,20);
menuB.no = i;
menuB.onRollOver = menubOver;
menuB.onRollOut = menubOut;
menuB.onRelease = menubRels;
}
function menubOver() {
this.tf.setTextFormat(txtFormat3);
fillRec(this,0x000000,100,20);
}
function menubOut() {
this.tf.setTextFormat(txtFormat2);
fillRec(this,0x444444,100,20);
}
function menubRels() {
num = slideNum[serNo];
for (i=1; i<num+1; i++) {
thumbnailContainer["thumb"+i].inside_mc.unloadMovie();
thumbnailContainer["thumb"+i].clear();
}
load_mcRels();
serNo = this.no;
loadThumb(serNo);
}
//サムネイル群のロード・表示とイベント
function loadThumb(serNo) {
num = slideNum[serNo];
for (i=1; i<num+1; i++) {
mc = thumbnailContainer.createEmptyMovieClip("thumb"+i, i);
mc.createEmptyMovieClip("inside_mc",i);
mc.inside_mc._x = -tw/2;
mc.inside_mc._y = -th/2;
mc.inside_mc.loadMovie("img"+serNo+"/sp"+i+".jpg");
mc._x = Stage.width/2;
mc._y = Stage.height/2;
mc.order = i;
drawLine(mc,0xffffff);
mc.onRollOver = rollov;
mc.onRollOut = rollot;
mc.onRelease = function() {
picNo = this.order;
loadPic(serNo,picNo);
};
setThumb(mc);
}
}
function rollov() {
this.rollov = true;
drawLine(this,0xff0000);
}
function rollot() {
this.rollov = false;
drawLine(this,0xffffff);
}
//サムネイル群の配置
function setThumb(mc) {
pOrder = mc.order;
mc._x = 75*((pOrder-1)%col);
mc._y = 60*Math.floor((pOrder-1)/col);
lag = pOrder*0.05;
mcTween = new Tween(mc, "_alpha", None.easeOut, 0, 0, lag, true);
mcTween.onMotionFinished = function() {
new Tween(mc, "_alpha", None.easeOut, 0, 100, lag/2, true);
};
}
//拡大写真のロードと表示
function loadPic(serNo, picNo) {
thumbnailContainer._visible = false;
var mcLoader:MovieClipLoader = new MovieClipLoader();
jpg = "img"+serNo+"/Lp"+picNo+".jpg";
mcLoader.loadClip(jpg,load_mc);
var oListener:Object = new Object();
oListener.onLoadInit = function() {
startx = Stage.width/2;
starty = Stage.height/2;
load_mc_w = load_mc._width/2;
load_mc_h = load_mc._height/2;
load_mcx = Stage.width/2-load_mc_w;
load_mcy = Stage.height/2-load_mc_h;
new Tween(load_mc, "_x", Regular.easeOut, startx, load_mcx, 0.5, true);
new Tween(load_mc, "_y", Regular.easeOut, starty, load_mcy, 0.5, true);
new Tween(load_mc, "_alpha", Regular.easeOut, 0, 100, 1, true);
new Tween(load_mc, "_xscale", Regular.easeOut, 0, 100, 0.5, true);
new Tween(load_mc, "_yscale", Regular.easeOut, 0, 100, 0.5, true);
load_mc.onRelease = load_mcRels;
};
mcLoader.addListener(oListener);
}
//拡大写真を非表示・サムネイル群再表示
function load_mcRels() {
mcTween = new Tween(load_mc, "_alpha", Regular.easeOut, 100, 0, 1, true);
thumbnailContainer._visible = true;
new Tween(thumbnailContainer, "_alpha", Regular.easeOut, 0, 100, 1, true);
mcTween.onMotionFinished = function() {
load_mc.unloadMovie();
};
slideShow_stop();
}
//送りボタン、戻りボタンのアクション
forward_btn.onRelease = fwSlide;
backward_btn.onRelease = bwSlide;
play_btn.onRelease = slideShow_play;
stop_btn.onRelease = slideShow_stop;
function fwSlide() {
if (picNo++>slideNum[serNo]-1) {
picNo = 1;
}
if (!picNo) {
picNo = 1;
}
loadPic(serNo,picNo);
}
function bwSlide() {
if (picNo--<2) {
picNo = slideNum[serNo];
}
if (!picNo) {
picNo = slideNum[serNo];
}
loadPic(serNo,picNo);
}
//スライドショーの開始・停止
function slideShow_play() {
play_btn._visible = false;
stop_btn._visible = true;
if (!picNo) {
picNo = 0;
}
fwSlide();
ID = setInterval(fwSlide, 4000);
}
function slideShow_stop() {
play_btn._visible = true;
stop_btn._visible = false;
clearInterval(ID);
}
//サムネイルに枠線付与
function drawLine(mc, color) {
mc.clear();
mc.lineStyle("2",color);
mc.moveTo(-tw/2,-th/2);
mc.lineTo(tw/2,-th/2);
mc.lineTo(tw/2,th/2);
mc.lineTo(-tw/2,th/2);
mc.lineTo(-tw/2,-th/2);
}
//ボタン類の塗り
function fillRec(mc, color, w, h) {
mc.clear();
mc.lineStyle("2",0x000000);
mc.beginFill(color);
mc.moveTo(0,0);
mc.lineTo(w,0);
mc.lineTo(w,h);
mc.lineTo(0,h);
mc.lineTo(0,0);
mc.endFill();
} |
pOrderの大きいものほど長くする
lagの間見えなくし、時間差をつける
lagの後フェイドイン
|