Make your own free website on Tripod.com

MovieClip._xscale and _yscale


The _xscale is the horizontal zoom relative to what the symbol is in the library. Not a relative value to the initial state on the stage.

When we assign a negative _xscale to a clip, the appearance look like we flip it horizontally.

It seems simple but here are several points we need to discuss:

1. Width of stroke:

The _xscale and _yscale are applied to "Fill"; How about the "Stroke" ?

Flash always tries to make stroke width homogenously the same. I dont know the detail how Flash implement the algorithm. No matter how we stratch and distort the Clip, the width of stroke is mantained well without distortion.

If we create a square with a stroke width of 5, and then we zoom it in by setting _xscale=_yscale=200; then we see a square of double size and also a widened stroke. If we zoom it out by setting _xscale=_yscale=50; then we see a half sized square and a narrowed stoke surround the fill.

What if we stretch the square by _xscale=200;_yscale=50; ? Will the stroke widened or narrowed ? Well, we see a stroke of intermediate width surround the fill. Do not expect the stroke will be widen for the right/left sides and narrow in top/bottom sides. By definition, the stroke should be homogenoeously the same.

I dont know how Flash decide the width of the Stroke in such condition. Anyway, it is not perfect. A side effect of "reminant" stroke remains on the screen. Sometimes, it even affect the "hitTest";

When we animate the clip, Flash will do invalidate Rect to clear the rect where the original position is and then do redraw to draw the clip to a new rect. Possibly, the invalidate Rect take the reference of the getBounds of the clip which is not so accurate for stroke. Some stroke is out of the rect and remains on the screen.

Try one:

Make a clip of 100x100 pix square with a stoke of 3 pix wide. 
_xscale=1;
_yscale=500;
onEnterFrame=function(){_x+=3;}

We will see the uncleared stroke remnants;

2. Negative and Zero _xscale:

When we set _xscale=0; Dont expect it will always be invisible. If there is no rotation, the width of the fill will be 0; However, if we have stroke, we can still see the stroke. The width of the stroke will not always be 0;

When we set _xscale=-100; The clip gets flipped horizontally. But, the reverse is not always true.

When we put a clip on the stage, we flip it horizontally to create an effect like we set _xscale=-100; Then we check the _xscale. No, the _xscale is not -100. It is 100. Flash interprete it as _rotation=180; not _xscale=-100; However, it is different from what we expect by setting _rotation=180;

When we have a clip with _xscale=-100, it is horizontally flipped. Then we duplicate that clip. The duplicated clip appears also horizontally flipped, however, the _xscale is positive 100; So, we need be careful, if we are doing _xscale animation.