BlendMode.LAYER; A must when changing the alpha property of a DisplayObject containing other DisplayObjects
I don’t know if you ever tweened a MovieClip’s alpha while this MovieClip contained multiple assets, but I kinda do this all the time (fade in ,fade out being the easiest transition for almost everything). The default way Flash handles this is by changing the alpha of every assets in the containing MovieClip (or Sprite). Sometimes it doesn’t matter but most of the time that’s not the behavior you would like it to have. When you have shapes or bitmaps that overlap or hide other graphical assets you will see what is under it when changing the alpha instead of actually changing the alpha of the container as if it was a whole.
Well I don’t know if it’s clear but I have an example below that should clarify that. Anyway, I have stumbled upon the solution to this while browsing through the help files for BlendMode. If you set the blendMode of your containing DisplayObject to BlendMode.LAYER Flash will consider this DisplayObject as only one layer and will change the alpha the way you normally think it would.
Here is the example that will illustrate my point better. The left Sprite is the reference object, the middle Sprite has no blendMode on and the right Sprite has a blendMode of BlendMode.LAYER. Mostly look at the colors while tweening and the overlapping regions of the green and blue ellipses.
I really wish I had found this earlier and I hope this will help others that were in my situation.
April 29th, 2008 at 3:55 am
Hi,
The example is not showing up
I’m using flash player 9.0.124.
Dont know if other people are also noticing this.
Cheers,
SIdney
April 29th, 2008 at 6:17 pm
There seemed to be a problem with the word press plugin I am using to embed the flash. Since I am using the title of the page as the url to this particular page the path to the flash file was different than on the home page. I seem to have it fixed now.
Thank you for pointing it out.
May 6th, 2008 at 8:06 am
BlendMode.LAYER…
当为包含子对象的DisplayObject或MovieClip设置alpha值的时候,默认是会把所有子对象都设置透明再叠加在一起,如中图的情况。如果把层混合模式设置为: BlendMode.LAYER ,Flash会认为该对象只有一….
May 12th, 2008 at 7:21 am
Oh, thanks for sharing! I was always wondering how to achieve that mode… and it was just simply Layer blend mode. I should have been read the manual in the first place
May 13th, 2008 at 2:26 pm
[…] All you need to do is set the container clip BlendMode to LAYER (BlendMore.LAYER). The Zedia Flash Blog has put up a straight forward example of the […]
May 27th, 2008 at 7:21 pm
[…] was really happy when I found out how to do proper fade outs of MovieClips containing other MovieClips, but I am even more happy now because I found how to do it in ActionScript 2. I don’t know why but […]
June 4th, 2008 at 8:02 am
Do you have to assign this value only once (let’s say at the time of creating the container’s content) or everytime tween has to be shown?
I have a similar (at least, that’s what I suspect) problem with clip containing Bitmap and white rectangle beneath it that acts as a border. Problem appears when the fadein/out is supposed to take place, showing transparent hole where the bitmap is supposed to be. Then, it suddenly appears when the alpha value reaches 100%.