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.

Cet article en Français

9 Responses to “BlendMode.LAYER; A must when changing the alpha property of a DisplayObject containing other DisplayObjects”

  1. Sidney de Koning Says:

    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

  2. dgelineau Says:

    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.

  3. Kevin Cao's Blog Says:

    BlendMode.LAYER…

    当为包含子对象的DisplayObject或MovieClip设置alpha值的时候,默认是会把所有子对象都设置透明再叠加在一起,如中图的情况。如果把层混合模式设置为: BlendMode.LAYER ,Flash会认为该对象只有一….

  4. Og2t Says:

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

  5. Andrew.blog » Fade Flash DisplayObjects without the overlay! Says:

    […] 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 […]

  6. Again on BlendMode (this time in AS2) | mc.blendMode = "layer" | zedia flash blog Says:

    […] 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 […]

  7. zgub Says:

    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%.

  8. Paulo Barcelos Says:

    Genius!

    I’ve been living up with this problem for ages! Can’t believe it was so simple….Thanks for the tip!

  9. oliver Says:

    I think this is more to do with cacheAsBitmap rather than “layer” blendMode, yes?
    this is why zgub’s having problems with white.

Leave a Reply


Close
E-mail It