AS Reference  :  Notes Index  :  Resources  :  About/Contact  :  Downloads

Masks

Making a mask

A mask can be used when you want to show only part of the content in a layer, or group of layers. To make a mask, do these things:

  1. Add a layer above the content you want to mask. If there are multiple layers with content to be masked, add the new layer above the top one.
  2. Convert the new layer to a mask layer by right-clicking on the layer name and choosing Mask. This will cause both the mask layer and the layer under it to be locked. Unlock the mask layer to put content in it. If there are muliple layers to be masked, drag each one up under the mask.
  3. Using a fill color that stands out over your content (it won't show in the final movie), draw the shape in the mask layer that you want to act as a window for the layer or layers below the mask. The shape of the mask determines what will show through from underlying layers (the opposite of a physical mask).
  4. To see how the final masked content will appear, lock both the mask layer and its underlying content layer(s).

Here's are two views of what the stage looks like with a jpg imported into the pink_flower layer and mask in the layer above that consists of a solid rectangle plus some text. One view (with layers unlocked) shows the photo and the mask above it; the other (with both layers locked) shows what the published swf will look like.

These are the steps to create that:

Mask over motion-tweened content

The example above is of a static mask over a static shape, but both the mask and the content in the layer below it can also contain moving parts (tweens, keyframe animation). Here is an example of the photo transitions shown on the more motion tweens page with the same mask as above in a layer above them (all layers of the photo transition movie were dragged under the mask):

Shape-tweened mask over motion-tweened content

And here is a rather garish example in which the photos are motion-tweened as before, and the mask layer has also been tweened (in this case, shape-tweened). Open maskflowers3.fla to see how the shape-tweening is implemented.

Keyframe mask for handwriting

Masks can also be used for handwriting or drawing effects, where an outline or shape on stage is to be progressively revealed. To make the handwriting sample below, I followed the following steps:

Below is what the timeline looks like after 4 steps of "F6, draw". Bigger strokes can be used in each keyframe if detail is not important. But check along the way to make sure the uncovering looks right; any mistakes made along the way will be carried through in every keyframe to the end of the animation and are hard to fix after the fact:

Intro
Flash: What & How
Example Sites
Create
Draw, Edit Shapes
Gradients
More Drawing Tips
Import
A Sample
Animate
Frames, Keyframes
Motion Tweens
More Motion Tweens
Shape Tweens
Masks
Control
Stop/Replay
Movieclips Intro
Movieclip Reference
Site Structure 1
Slideshow Movieclip
Contact Form
Scroll Resume
Preloader
Site Structure 2
Publish
Display Options
Player Detection
Optimize
AS 2.0 Basics
Intro to Syntax
Playhead Commands
Playhead Cmds 2
Coded Tween
onEnterFrame
Intro to Classes
Declare/Assign
Comments, Trace
Simple Data Types
Arrays & Objects
Code Blocks
Operators
Beyond Buttons
Code Structure
Toggle Controls
Group of Buttons
Drag and Hit
Distort Magnifier
Scroll Text
Bee Game
Dart Shooter
Sound Control
Easing Slider
Easing Slider 2
Components Intro
Timers & Delays
Dynamic Content
Intro
Drawing API
Create Text
Attach Movieclips
Easing Slider 3
Easing Slider 4
Load jpg/swf
Sliding Viewer
Preload swf
XML
Easing Slider 5
Server Comm
LoadVars (w/ PHP)
AS - PHP Lookup
Text File
Database 1:LoadVars
Database 2:Remoting
Read from directory
AS 2.0 Classes
Intro
Math
Key
Date
Color
EventDispatcher
New Samples
Pie Chart
Event-model Emailer
Tween Sequence
Fuse Sequence
SVG in Flash
Bitmap Topo
SWF as Data Holder
Two-level Menu
Yahoo! Flash Maps
Class-based Game
ASTB Samples
Disclaimer
3D Outlines
Bounce Collide
Address Book
Save Drawings
Home  :  Notes Index  :  Resources  :  About/Contact  :  Downloads