Actionscript ile Sahnenin tam ortasını hesaplamak
Genelde problem olan ve sık ıhtıyac duyulan bir kod .Sahnenin tam ortasını hesaplayıp bu movie clipleri dizmek Basit bir function ile kolay hale gelıor
this._y = this._parent._height / 2 - (this._height / 2);
this._x = this._parent._width / 2 - (this._width / 2);
};
// USAGE:
// Center MovieClip
// by: Gustavo Perez
// aka pcMan @ www.mx-motion.com
//——————————-
// creates a stage-sized border rectangle
lineStyle(0.25, 0xFF6600, 100);
moveTo(0, 0);
lineTo(Stage.width, 0);
lineTo(Stage.width, Stage.height);
lineTo(0, Stage.height);
lineTo(0, 0);
// creates center crossing lines
moveTo(Stage.width/2-50, Stage.height/2);
lineTo(Stage.width/2+50, Stage.height/2);
moveTo(Stage.width/2, Stage.height/2-50);
lineTo(Stage.width/2, Stage.height/2+50);
// creates a new movieclip
createEmptyMovieClip("_mc", 0);
with (_root._mc) {
beginFill(0xFF0000, 10);
lineStyle(.25, 0×000000, 10);
moveTo(0, 0);
lineTo(200, 0);
lineTo(200, 200);
lineTo(0, 200);
lineTo(0, 0);
endFill();
moveTo(_width/2, 0);
lineTo(_width/2, _height);
moveTo(0, _height/2);
lineTo(_width, _height/2);
}
// This prototype get self and _parent size to center clip
// Use it under your own risk xD
// centering relative to self size and parent =)
_mc.centerClip();
