Make your own free website on Tripod.com
_height==76.7 or 76.65
ericlin@ms1.hinet.net 

The properties of a movieClip that has a prefix of "_" like _x,_y,_alpha,_rotation,_width,_height are not only kinds of "variable"; When we say _height=70, it evoke a repaint action. It is different from h=70; Becareful, h=70; h+10 will be 80; But _alpha=70;_alpha+10 does not necessarily to be 80;

Here is a weird test. In a project about graphic equilizer, we need animate the height of a vertical bar. We try to reduce the height by 0.4 until it is 75.5; if (_height==75.5){stop();}. OK, click the button, the textbox will trace the value of _height. Every step is well, the _height decreased by 0.4 until 76.7. And you know, the height will never be 75.5, it is 75.45;

This movie is not easy to reproduce. It occurrs only on specific height and _y of the movieClip.

This problem can be fixed by h-=4; and _height=h; For compare, we compare with h, not _height;

Here is another problem. It is easier to understand and easier to reproduce the side effect.

We try to set an end alpha to a movieClip. When the _alpha value is larger than the endAlpha, it decreases by 10; If _alpha is smaller than endAlpha , it increase _alpha by 10; Well, that means, if _alpha==endAlpha, it does nothing, else the _alpha will increase or decrease by 10;

If we set endAlpha=60, we expect the _alpha will goes down from 100->90->80->70->60; But, it does not. If you trace the _alpha value, it will be 89.84375->79.6875->69.53125->59.375; That is, it is not an integer. It will never ==60; So, it flickering. The _alpha value looping between 69.53125 and 59.375;

The left side box fix the problem. It use a normal variable alpha, not _alpha. So, alpha will go 100->90->80->70->60; We compare alpha==60; And it works;

Conclusion: it is better not do mathmatics calculation to properties _x,_y,_width,_height,_alpha,_rotation. You can do calculation to  x,y,width,height, alpha and then assign its data to _x,_y,_width,_height,_alpha,_rotation.

download the zipped fla of these two demo swf