Wrong line height
Hello I am having a simple problem
The width is perfect when i draw the line but the height is 3 times 37. What am i doing wrong?
var rectHeight = 37;
var rectWidth = 37;
tmp_big._x = (Stage.width-1280)+ 640; // Just trying to put the shape in a certain position
tmp_big._y = Stage.height/2; // Change registration point
First, you might want to review the recommended syntax for movieclip.lineStyle
Second, I think if you change
That might fix it.
Thanks Medyman. But if I put this:
The line comes out round and the height has the same problem. So here is a workaround I did.
tmp_big.lineStyle(rectWidth, color_tmp, 100);
tmp_big._x = (Stage.width-1280)+ 640;
tmp_big._y = Stage.height/2;
The problem with this is that the registration point os no longer middle. Is there a reason ?
tmp_big._x = ((Stage.width-1280)+ 640) - (rectHeight/2);
tmp_big._y = (Stage.height/2) - (rectWidth/2);
What is it that you're going for? A 37x37 square?
Well the thing is I will give it a certain number for height and width and the registration point should be in the middle. I t could be a square or rectangle.
Ahh, I see...
Well, the registration point of any movieclip that is created dynamically will always be in the upper left hand corner. You can't change the registration point with ActionScript.
You can, of course, change a movieclip's position to mimic the behavior of something that has a registratin point in the center. To do this you would need to create a container around the rectangle/square. Then you'll align the center of the rectangle/square to the upper left hand corner of the container movieclip.
The commented out actions will center the container on the stage.
var rectHeight:Number = 120;
var rectWidth:Number = 300;
var container:MovieClip = this.createEmptyMovieClip("container", this.getNextHighestDepth());
var r:MovieClip = container.createEmptyMovieClip("rectangle", container.getNextHighestDepth());
r._x = -r._width/2
r._y = -r._height/2
// Centers the container on the stage.
// container._x = Stage.width/2;
// container._y = Stage.height/2;