import mx.transitions.Tween;
import mx.transitions.easing.*;
//ステージ中央の座標
var cx = Stage.width / 2;
var cy = Stage.height / 2;
//表示文字列を配列で定義
var str = ["うさぎ追いし かの山", "こぶな釣りし かの川", "夢は今も めぐりて", "忘れがたき", "ふるさと"];
//文字列毎の文字のサイズ・色・表示位置
var txt_size = [24, 32, 48, 24, 48];
var txt_color = [0x009900, 0x0033ff, 0xff3300, 0x0033ff, 0x009900];
var zahyo = [{x:50, y:cy - 15}, {x:50, y:cy - 20}, {x:0, y:cy - 30}, {x:50, y:cy - 15}, {x:200, y:cy - 30}];
//表示文字の深度(同じ深度を指定すると入れ替わる)
var depth = [10, 10, 10, 10, 11];
//文字列を表示するのに要する時間(1秒が60)
var dur = [180, 180, 200, 80, 180];
//文字列が表示された後、次の表示までの間隔(時間)
var interval = [60, 60, 90, 30, 240];
//最初の文字列の表示開始までの時間
var intro = 60;
//文字列の数を取得
var lineNum:Number = str.length;
//マスク用矩形(ムービークリップ)の作成
var mask_mc = this.createEmptyMovieClip("maskRec", 100);
//最初の表示文字列の番号
var n = 1;
//最初の文字列表示前に intro だけ間をおいてdisplaystrを開始
tweenIntro = new Tween(mask_mc, "_alpha", None.easeOut, 100, 100, intro, false);
tweenIntro.onMotionFinished = function()
{
displaystr(n);
};
//指定文字番号の文字列を指定のサイズ・色・配置で表示
function displaystr(n)
{
txtSize = txt_size[n - 1];
txtColor = txt_color[n - 1];
//ポイント/ピクセル変換(Macでは要調整?)し、テキストフィールドの大きさ指定
w = txtSize * 4 / 3 * str[n - 1].length;
h = txtSize * 4 / 3;
//文字列表示用ムービークリップ・テキストフィールド作成
str_mc = this.createEmptyMovieClip("str_mc", depth[n - 1]);
str_mc.createTextField("tf",depth[n - 1],0,0,w,h);
str_mc.tf.text = str[n - 1];
txtFormat(str_mc);
str_mc._x = mask_mc._x = zahyo[n - 1].x;
str_mc._y = mask_mc._y = zahyo[n - 1].y;
appearstr();
}
//文字列のスライド表示(マスクが右方向に拡大して徐々に見えるようになる)
function appearstr()
{
lag1 = dur[n - 1];
lag2 = interval[n - 1];
mask_mc._x = kC_w / 2 - w / 2;
bgColor = 0x3366ff;
fillRec(mask_mc);
tweenL0 = new Tween(mask_mc, "_width", None.easeOut, 0, w, lag1, false);
str_mc.setMask(mask_mc);
tweenL0.onMotionFinished = function()
{
tweenL1 = new Tween(mask_mc, "_width", None.easeOut, w, w, lag2, false);
tweenL1.onMotionFinished = function()
{
if (n >= lineNum)
{
str_mc.removeMovieClip();
n = 1;
}
else
{
n++;
}
displaystr(n);
};
};
}
//矩形の描画・塗り
function fillRec(mc)
{
mc.beginFill(bgColor);
mc.moveTo(0,0);
mc.lineTo(w,0);
mc.lineTo(w,h);
mc.lineTo(0,h);
mc.lineTo(0,0);
mc.endFill();
}
//文字のフォーマット
function txtFormat(mc)
{
var format = new TextFormat();
with (format)
{
size = txtSize;
color = txtColor;
align = "left";
bold = true;
}
mc.tf.setTextFormat(format);
} |
import mx.transitions.Tween;
import mx.transitions.easing.*;
import flash.filters.GlowFilter;
//グローフィルターの設定
var glow:GlowFilter = new GlowFilter(0xffffff, 0.8, 2, 2, 8, 3);
cx = Stage.width / 2;
cy = Stage.height / 2;
var str = ["うさぎ追いし かの山", "こぶな釣りし かの川", "夢は今も めぐりて", "忘れがたき", "ふるさと"];
var txt_size = [24, 32, 48, 24, 48];
var txt_color = [0x33ffcc, 0x66ccff, 0xff3300, 0x33ffcc, 0x66ccff];
var zahyo = [{x:50, y:cy - 15}, {x:50, y:cy - 20}, {x:0, y:cy - 30}, {x:50, y:cy - 15}, {x:200, y:cy - 30}];
var depth = [10, 10, 10, 10, 11];
var dur = [180, 180, 200, 80, 180];
var interval = [60, 60, 90, 30, 240];
var intro = 60;
var lineNum:Number = str.length;
mask_mc = this.createEmptyMovieClip("maskRec", 100);
var n = 1;
tweenIntro = new Tween(mask_mc, "_alpha", None.easeOut, 100, 100, intro, false);
tweenIntro.onMotionFinished = function()
{
displaystr(n);
};
function displaystr(n)
{
//下地の文字列表示
txtColor = 0xdddddd;
txtSize = txt_size[n - 1];
w = txtSize * 4 / 3 * str[n - 1].length;
h = txtSize * 4 / 3;
str_mc2 = this.createEmptyMovieClip("str_mc2", -1);
str_mc2.createTextField("tf",-1,0,0,w,h);
str_mc2.tf.text = str[n - 1];
txtFormat(str_mc2);
str_mc2._x = mask_mc._x = zahyo[n - 1].x;
str_mc2._y = mask_mc._y = zahyo[n - 1].y;
mc2Tween = new Tween(str_mc2, "_alpha", None.easeOut, 0, 100, 30, false);
//表の文字列表示用MC・テキストフィールド作成・グロフィルター付与・マスクセット
txtColor = txt_color[n - 1];
txtSize = txt_size[n - 1];
w = txtSize * 4 / 3 * str[n - 1].length;
h = txtSize * 4 / 3;
str_mc1 = this.createEmptyMovieClip("str_mc1", depth[n - 1]);
str_mc1.createTextField("tf",depth[n - 1],0,0,w,h);
str_mc1.filters = [glow];
str_mc1._x = mask_mc._x = zahyo[n - 1].x;
str_mc1._y = mask_mc._y = zahyo[n - 1].y;
str_mc1.setMask(mask_mc);
//時間差をおいて文字表示
var timelag = 60;
lagTween = new Tween(mask_mc, "_alpha", None.easeOut, 100, 100, timelag, false);
lagTween.onMotionFinished = function()
{
str_mc1.tf.text = str[n - 1];
txtFormat(str_mc1);
appearstr();
};
}
function appearstr()
{
dur1 = dur[n - 1];
dur2 = interval[n - 1];
mask_mc._x = kC_w / 2 - w / 2;
bgColor = 0x3366ff;
fillRec(mask_mc);
tweenL0 = new Tween(mask_mc, "_width", None.easeOut, 0, w, dur1, false);
str_mc1.setMask(mask_mc);
tweenL0.onMotionFinished = function()
{
tweenL1 = new Tween(mask_mc, "_width", None.easeOut, w, w, dur2, false);
tweenL1.onMotionFinished = function()
{
if (n > lineNum - 1)
{
stop();
video.stop();
replay_btn._visible = true;
replay_btn.onRelease = function()
{
str_mc1.removeMovieClip();
n = 1;
replay_btn._visible = false;
displaystr(n);
video.play();
};
}
else
{
n++;
displaystr(n);
}
};
};
}
//リプレイボタンの設置
this.createEmptyMovieClip("replay_btn",200);
replay_btn.createTextField("tf",200,0,0,50,25);
replay_btn.tf.text = "REPLAY";
replay_btn._x = Stage.width - 80;
replay_btn._y = Stage.height - 30;
fm = new TextFormat();
fm.color = 0xffffff;
replay_btn.tf.setTextFormat(fm);
replay_btn._visible = false;
function fillRec(mc)
{
mc.clear();
mc.beginFill(bgColor);
mc.moveTo(0,0);
mc.lineTo(w,0);
mc.lineTo(w,h);
mc.lineTo(0,h);
mc.lineTo(0,0);
mc.endFill();
}
function txtFormat(mc)
{
var format = new TextFormat();
with (format)
{
size = txtSize;
color = txtColor;
align = "left";
bold = true;
}
mc.tf.setTextFormat(format);
}
|