2008.10.09 Thursday
Flash の中央寄せ −その2−
Flash の中央寄せ−その1− に動きをつける。
--------------------------------------
HTML側の設定
--------------------------------------
width="100%" height="100%"
<param name="scale" value="noScale" />
<param name="salign" value="TL" />
scale="noScale" salign="TL"
(Firefox の場合、さらに)
<style type="text/css">
<!--
html,body { height: 100%; }
//-->
</style>
--------------------------------------
test_mcの基準点がtest_mcの中央にある場合
--------------------------------------
※test_mcに設定する。
//設定
onClipEvent(load){
Stage.scaleMode = "noScale";
Stage.align = "TL";
//中央へ寄るスピード
var speed = 5;
}
//画面のサイズが変更になった時に中央に寄る
onClipEvent(enterFrame){
var myX =Math.floor( Stage.width/2);
var myY =Math.floor(Stage.height/2);
this._x += (myX-this._x)/speed;
this._y += (myY-this._y)/speed;
}
------------------------------------------
test_mcの基準点がtest_mcの左上原点にある場合
------------------------------------------
※test_mcに設定する。
//設定
onClipEvent(load){
Stage.scaleMode = "noScale";
Stage.align = "TL";
//中央へ寄るスピード
var speed = 5;
}
//画面のサイズが変更になった時に中央に寄る
onClipEvent(enterFrame){
var myX =Math.floor( (Stage.width-this._width)/2);
var myY =Math.floor( (Stage.height-this._height)/2);
this._x += (myX-this._x)/speed;
this._y += (myY-this._y)/speed;
}
--------------------------
Flash制作/F (f-sphere)
http://www.f-sphere.com/