Flash / Actionscript custom alpha blending: Class NandAlphaBlender

Case

For one of our projects we needed a special kind of blending of two sprites: the overlap of two sprites should be hidden whereas the rest should maintain it's original alpha levels. As far as i know, this behavior can not be achieved with regular sprite-blending so some extra logic is needed to generate a new bitmap with this new layout.

Possible solution 

One could create a class that generates a new DisplayObject that can be used on stage to simulate this behavior.

I gave it my best shot and you can find a class with that logic here

Just extract the zip in your Flex / Flash source directory and import the class in your source code. Now call the static function NandAlphaBlender.getBitmap(displayObject1, displayObject2) to get the generated bitmap. The passed DisplayObjects should have the same parent and the returned Bitmap will have the same coordinates as the original images.

The code should look something like this (where circle and rect are sibling displayObjects):

package {
...
 
 import nl.kingsquare.NandAlphaBlender;
 ... 
 ...  
   var result:Bitmap = NandAlphaBlender.getBitmap(circle, rect);
   addChild(result);
   result.x += 200;
...
}

And the result should be something like shown above.

It took me quite a while to get a grip on this, so i hope this helps you!

3 reacties: RSS feed voor commentaar op dit item
viagra
viagra
Op 04-02-2012 09:41
http://www.viagra.gd viagra Online without prescription asdasd http://www.viagra.gd - viagra asdasd
http://www.viagras.name viagra asdasd http://www.viagras.name - viagra asdasd
http://www.cialisgeneric.us Generic cialis asdasd http://www.cialisgeneric.us - Generic cialis asdasd
http://www.viagraonlinedrugstore.net Viagra online asdasd http://www.viagraonlinedrugstore.net - Viagra online asdasd
http://www.generic-viagra.us Generic viagra asdasd http://www.generic-viagra.us - Generic viagra asdasd
http://www.viagra-online-without-prescription.biz Viagra Online Without Prescription asdasd http://www.viagra-online-without-prescription.biz - Viagra Online Without Prescription asdasd

4
viagra
viagra
Op 02-02-2012 10:18
http://www.viagra-online-pharmacy.org Viagra online asdasd http://www.viagra-online-pharmacy.org - Viagra online asdasd
http://www.viagra.gd viagra asdasd http://www.viagra.gd - viagra asdasd
http://www.cialisgeneric.us Generic cialis asdasd http://www.cialisgeneric.us - Generic cialis asdasd
http://www.genericviagra.cc Generic viagra asdasd http://www.genericviagra.cc - Generic viagra asdasd
http://www.viagracheap.biz Cheap viagra asdasd http://www.viagracheap.biz - Cheap viagra asdasd
http://www.onlinecialis.biz Cialis online asdasd http://www.onlinecialis.biz - Cialis online asdasd

6
Dhr. ing. T. de Koning
Dhr. ing. T. de Koning
Op 07-12-2009 19:11
One could also retrieve a sprite to use as a mask from this class.

Plaats een reactie

Terug naar het weblog overzicht