MC positioning to stage borders in 100x100, center aligned movies

I’m always using “100% x 100% noscale” settings while creating Flash sites. A few years ago I’ve learned how to position some movie clips to the stage borders. The only solution was to make “TL” movie align. But I like center align (don’t ask why, I have some reasons). I tried to calculate right position with center align, but without success.

A few days ago I tried again and was surprised how simple the solution is. It’s so simple that I don’t believe no one uses it already, but I still haven’t seen it anywhere.

This example is if you have movie clip 800x600 and 100x100 scene with center align.


movie._y = Math.round((Stage.height/2-300)*-1);//top
movie._x = Math.round((Stage.width/2+400))-movieWidth;//right
movie._y = Math.round((Stage.height/2+300))-movieHeight;//bottom
movie._x = Math.round((Stage.width/2-400)*-1);//left