2012-05-19 29 views
1

我正在做影片剪辑的放大和缩小。我通过mc.height获得原始高度。缩放动画片段后,我需要增加影片剪辑的高度。所以我使用了mc._height属性。 但它提供了更高的价值,它不是原始价值。但它也会随着价值的减少和价值的变化而变化。as2闪光灯影片剪辑_height&height之间的区别是什么

请帮帮我。

谢谢。

嗨,我正在做缩放概念。在缩放movieclip宽度工作正常。但在补间图像的情况下,高度异常增加。什么原因我没有找到。请帮助我。

this.onMouseMove = function() { 
constrainedMove(bg_mc, 4, 1); 
}; 

function constrainedMove(target:MovieClip, speed:Number, dir:Number) { 
var mousePercent:Number = _xmouse/Stage.width; 
var mSpeed:Number; 
if (dir == 1) { 
    mSpeed = 1-mousePercent; 
} else { 
    mSpeed = mousePercent; 
} 
target.destX = Math.round(-((target._width-Stage.width)*mSpeed)); 

    target.onEnterFrame = function() { 
    if (target._x == target.destX) { 
     delete target.onEnterFrame; 
    } 
       else if (target._x>target.destX) { 
     target._x -= Math.ceil((target._x-target.destX)*(speed/100)); 
    } 
       else if (target._x<target.destX) { 
     target._x += Math.ceil((target.destX-target._x)*(speed/100)); 
    } 
}; 
} 
+0

感谢您的意见 – user1120998

回答

3

有ActionScript 2中没有.height属性,如您在AS3中指出其._height,针对ActionScript 3

它更可能是你的代码作为一个侧面说明所有旧变量被_visible,_width,_height等。这些被更改为可见,宽度,高度等。

希望这有助于。

编辑:

如果使用_xscale_yscale,那么你可能无法获得宽度和高度是否符合预期。这里是一个使用Matrix的例子。首先在舞台上创建一个盒子,并给盒的实例名使它100x100的大小:

import flash.geom.Matrix; 

// will trace 100 
trace(box._width); 

// will trace 100 
trace(box._height); 

// get the current matrix and scale it by factor of two - doubling it 
var matrix = box.transform.matrix; 
matrix.scale(2,2); 

// apply the matrix back to the movieclip 
box.transform.matrix = matrix; 

// will trace 200 
trace(box._width); 

// will trace 200 
trace(box._height); 

有一个很好的文章上使用 - Matrix in actionscript 2 by senoculor

我真的希望这可以帮助你,如果是的话那么请将答案标记为正确。

+0

感谢您的回复。然后,如何在缩放动画片段后增加动画片段的高度。 – user1120998

+0

感谢您的回复。 – user1120998

+0

对于movieclip我跟踪(mc._width)。我得到宽度为120.为什么会出现这个问题。 – user1120998

0

我只是想在本文中更新一些有用的信息。这两个版本的高度将突出显示为蓝色,因为它们都以关键字形式存在。大多数对象使用._height属性,但Stage类使用.height。 这有点令人困惑,但却是与AS2不一致的完美例子。

Stage.height 
MovieClip._height 
相关问题