Search code examples
flashactionscript-2zoomingmovieclip

what is difference between _height & height for movie clip in as2 flash


I am doing zoom in and out for Movie clip. I get the original height by mc.height. After scale the movieclip, i need the increased height of movie clip. So i have used the mc._height property. But it gives more higher values it is not original value. But also it changes on roll over within the value less and more value.

Pls Help me.

Thanks.

Hi, I am doing zooming concepts. On zooming movieclip width is working correctly. But in case of tweening image the width & height is increasing abnormally. What is reason i did not find that. Pls help me.

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));
    }
};
}

Solution

  • There is no .height property in Actionscript 2, as you pointed out its ._height, its more than likely that you have code for Actionscript 3.

    As a side note all older variables in AS3 were _visible, _width, _height etc. These were changed to visible, width, height etc.

    Hope this helps.

    EDIT:

    If you use _xscale or _yscale then you may not get the width and height you expect. Here is an example using a Matrix. First create a box on the stage and give instance name of box make it 100x100 in size:

    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);
    

    There is a good article on using - Matrix in actionscript 2 by senoculor

    I really hope this helps you, if it does then please mark the answer as correct.