正如我在上面所描述的,这是另一种方法。这与更改注册点的效果相同,而无需处理子组件和层。
基于我在这里找到的教程:http: //theflashconnection.com/content/how-to-change-registration-point-as3#viewSource
var heightChange:int = 200;
setRegPoint(mc_player, 0, mc_player.height);
var myTween:Tween = new Tween(mc_player,"height",Strong.easeOut,mc_player.height,mc_player.height - heightChange,2,true);
function setRegPoint(obj:DisplayObjectContainer, newX:Number, newY:Number):void {
//get the bounds of the object and the location
//of the current registration point in relation
//to the upper left corner of the graphical content
//note: this is a PSEUDO currentRegX and currentRegY, as the
//registration point of a display object is ALWAYS (0, 0):
var bounds:Rectangle = obj.getBounds(obj.parent);
var currentRegX:Number = obj.x - bounds.left;
var currentRegY:Number = obj.y - bounds.top;
var xOffset:Number = newX - currentRegX;
var yOffset:Number = newY - currentRegY;
//shift the object to its new location--
//this will put it back in the same position
//where it started (that is, VISUALLY anyway):
obj.x += xOffset;
obj.y += yOffset;
//shift all the children the same amount,
//but in the opposite direction
for(var i:int = 0; i < obj.numChildren; i++) {
obj.getChildAt(i).x -= xOffset;
obj.getChildAt(i).y -= yOffset;
}
}