Change the height of a movieclip from a registrati

2019-08-07 01:29发布

问题:

Is there a way to extend only the bottom part of a dynamic Movieclip? I tried to change the height or to scale my mc but it always makes the change relativity to the center of the Movieclip. I guess I should define a registration point and change the height according to it but i'm not sure of how to do it. Hope someone can guide me. Thanks.

回答1:

http://www.flashwonderland.com/transformation-matrix/transformation-matrix-2.html

You can use matrix transforms to achieve that effect.

for a scale from the top use something like this:

var scaleFromTopY:Number = 2;// change this to the correct number.
var scaleFromTopX:Number = 1;// change this as well

var topScaleMatrix:Matrix = new Matrix(
        scaleFromTopX, 0,
        0, scaleFromTopY,
        0, (mc.height*scaleFromTopY)/2 // Make this last part into -(mc.height*scaleFromTopY)/2 to scale from the bottom
);
mc.transform.matrix = topScaleMatrix;

You can also combine matrices with Matrix.concat(m:Matrix);



回答2:

In Flash the registration point can never be changed, to get around this, you must position all the child elements where you want them in relation to the (0,0) point. All transformations will happen around this (0,0) point no matter where the content is placed inside the DisplayObject.