SWFC Manual


Basic usage of swfc   Fonts   Shapes   ActionScript   Buttons   >Blend Modes<   Filters  

6.Blend Modes

Blend modes were introduced in Flash 8. They allow to use different alrithmetrics when it comes to putting transparent (or semi transparent) shapes or images on top of each other. The diffent blend modes are:

normal
layer
multiply
screen
lighten
darken
add
substract
difference
invert
alpha
erase
overlay
hardlight

For example, in order to set a "invert" blend mode:

Code listing 6.1

.flash filename="invert.swf" fps=50 bbox=511x127
.jpeg pic stripe.jpg
.put pic
.font arial Arial.ttf
.text txt font=arial text="Test inverted blend mode... ABCDEFGHIJKLMNOPQRSTUVWXYZ" size=200%

.put txt x=512 y=120 blend=invert
.frame 700
.change txt x=-4096
.end

The layer blend modes is especially useful, if you want to make sprite transparent. Compare the two stacks of rectangles in the next example. In the left one (set without layer), when the sprite is made transparent via alpha=50%, the rectangles also are transparent in respect to each other- i.e., you don't get a transparent image of a stack of rectangles, you get an image of a stack of transparent rectangles. On the right side, the stack is set with layer, and only the whole sprite get's transparent.

Code listing 6.2

.flash filename="layer.swf" fps=50 bbox=511x127
.jpeg background stripe.jpg
.put background

.box b1 fill=green width=100 height=100
.box b2 fill=cyan width=100 height=100
.box b3 fill=blue width=100 height=100
.sprite s1
    .put b1
    .put b2 x=25 y=25
    .put b3 x=50 y=50
.end
.sprite s2
    .put b1
    .put b2 x=25 y=25
    .put b3 x=50 y=50
.end

.put s1 alpha=50%
.put s2 alpha=50% x=300 blend=layer

.end


Previous: Buttons SWFC Manual: Blend Modes Next: Filters