Basically, I wanted to center (_x only) an MC on the stage:
mcloader._x = (Stage.width/2)-(((mcloader.ball0._width*DENOMINATION)+BALLGAP*(DENOMINATION-1))/2);
where
DENOMINATION=5 //there are 5 balls
BALLGAP=10 //space between the balls
“mcloader” is an empty MC where 5 balls named [“ball” + i] are attached.
[COLOR=DarkRed]It’s a preloader[/COLOR]. Balls will gradually appear after every 20% progress of movie loaded, hence 5 balls.
below this script is a dynamic event handler:
i=1;
RATEINT=20; //ball will appear after every 20%
ratecurr=RATEINT;//current rate
_root.onEnterFrame = function() {
total = _root.getBytesTotal();
bloaded = _root.getBytesLoaded();
percent = Math.ceil((bloaded/total)*100);
if (percent<100) {
if (percent>=ratecurr) {
mcloader.ball0.duplicateMovieClip("ball"+i, i);
mcloader["ball"+i]._x = BALLGAP+mcloader.ball0._width+mcloader["ball"+(i-1)]._x;
i++;
ratecurr += RATEINT;
}
} else { this.onEnterFrame = null;}
};
stop;
At one time, the whole MC group will center. But then after testing it, it will position somewhere >Stage.width/2.
This is in Frame 1. Does Flash evaluate the dynamic event handler first before reading the scripts outside the this.onEnterFrame scope??