0
votes

I have a dynamically created movie clip which contains a text field.

I then rotate the move clip by 20 degrees.

I then want to center the clip on the stage. But the width and height readings, along with positioning x and y makes it position in the wrong place, which I guess is due to the registration point.

Is there a work around to this?

This is flash 8, as2

2

2 Answers

0
votes

Center align the text field to the movie clip. If you are dynamically setting the text and the text field is auto sizing, remember to re-apply the center alignment of the text field:

//Assuming mc is your MovieClip instance and tf is the child TextField instance
var tf = mc.tf;

//Reading the width and height of the TextField will remain accurate and unchanged by it's parent's rotation as it's rotation remains zero.
tf._x = -(tf._width / 2);
tf._y = -(tf._height / 2);

If you keep the movie clip at the center of the stage, the text field will appear to stay center as well. Regardless of the rotation of the movie clip.

0
votes

code to make a mc with reg point in middle

var mc:movieclip = new movieclip
mc.graphics.beginFill(0x000000,0);
mc.graphics.drawRect(-1,-1,2,2);
mc.graphics.endFill();

code to put this center reg point mc in the middle of the stage

 mc.x = stage.stageWidth / 2;
 mc.y = stage.stageHeight / 2;