Make your own free website on Tripod.com
The reveal of underlying shape during alpha tween
by ericlin

In previous article , I made a movie about alpha fading of a colorful lady bug, if we watch that central white spot carefully, we see a transient "graying" out in the white spot before it is bright again. If we zoom out that movie to check, we know that the "graying out" is the reveal of underlying black spot. It is very ugly and annoying.

Yes, it is hard to tolerate. 

What is the principle for Flash to handle the _alpha ? Should'nt it merge the layers first before alpha processing ?


Desired and undesired alpha tween

Maybe you are still puzzled about my complaints. Before we discuss further, please check this movie.  

Please adjust the alpha to see what happens.

The upper row contains only one shape. The alpha tween is what we desired. When the alpha is reduced, the whole appearance does not change much except the transparency.

The second row are movieClips containg two shapes distributed in different layer. For example, the bullet is created by two shapes, one black circle in the bottom layer and one white square in the top layer with half overlapping. It seems to be a perfect bullet clip before alpha tween. When we tween the alpha, those two shapes in different layer behaves as independent  two elements. Thus, the alpha tween reveals the underlying shape. That is what I said "ugly".


The formula 

endR value=topR*alpha+(1-alpha)*bottomR;
endG value=topG*alpha+(1-alpha)*bottomG;
endB value=topB*alpha+(1-alpha)*bottomB;


Dispatching of alpha instead of merging layers

If clip contains elementA and elementB, when we set clip._alpha=30, what result shall we get ?

If we borrow the terms in photoshop, we might believe that, Flash will first process a layer-merge for elementA and elementB into one "flat painting" and then set the flat painting 30% alpha.

No , it is not the case. Flash does not merge the layers first. It dispatch the alpha to each layer.

Flash just turns "clip._alpha=30" into something similar to " elementA._alpha=30 and elementB._alpha=30;" without "merging layer first";

If we also set clip.elementA._alpha=70, then the result is "elementA._alpha=21 and elementB._alpha=30";

If clip contains 10 elements when we set clip._alpha=30, well, this is not a simple work such as to set the _alpha of end merged flat painting. In fact, the work includes setting the _alpha of 10 elements and then processing the calculation from bottom up. It is a significant heavy work.


download files used in this article


email: ericlin@ms1.hinet.net