Flash Course

You can create Mask Layers to show and hide parts of your content in a Flash presentation.
A Mask works like a window blocking out everything but a certain area that you define. A mask controls the visible area in one ore more layers. Any shape, symbol or text object can be used as a mask.
The shape you place in a Mask Layer defines the area that will be visible in the "Masked Layers" below it.
You can also animate a Mask to create great effects in your Flash presentation.

- When creating a Mask Layer, it is important not to mix elements. For example, don't use an editable shape and a group on the same mask layer, keep it simple.

Creating Masks

For creating a masking effect, you first crate a Mask Layer in the Timeline. Then you must have one (or more) linked Layer below it (dedfined as Masked).
Any layer can be converted into a mask layer, by right-clicking on its name, then choose the Mask option.
With this method, the Layer below it will automatically be converted into a "Masked Layer", and both will be locked, as shown in the image below.
Mask and Masked Layers

Here is another way to create a Mask Layer:
- Click on the name of a Layer to select it, then click Modify -> Timeline -> Layer Properties (or right-click and choose Properties). The Layer Properties window appears (shown in the picture below), click the Mask checkbox, and then click OK.
Properties Layer
The layer is converted into Mask Layer, without to be locked. The Layer below remains as it is (unaffected). For this layer to be linked to the Mask Layer above, it must be defined as a Masked Layer.
Click the layer name of the layer directly beneath the mask layer, then click Modify -> Timeline -> Layer Properties (or right-click and choose Properties) to open the Properties window. In this window enable the Masked checkbox, and then click OK.
- A mask layer only affects the linked layers beneath it, and you can include as many Masked Layers you want, by dragging the layer beneath the Mask Layer.

In the next example we animate a Mask Layer to create a masking effect.
  1. Open a new Flash document and import an image on the Stage (with File -> Import -> Import to Stage).
  2. Add a new Layer in the Timeline (with click Insert -> Timeline -> Layer) and convert it in "Mask" (right-click on the layer name, choose Properties, then in the "Layer Properties" window enable the Mask checkbox, and click OK).
  3. In this Mask Layer draw an oval (with the "Oval Tool") in the left side of the picture on the Stage. This oval will be the visible area.
  4. Convert the oval into Movie Clip Symbol (from Modify -> Convert to Symbol, choose "Movie Clip" type, and click OK).
  5. Right-click on Frame 40 in Layer 1, and choose Insert Keyframe.
    - With this, the Flash presentation will contain 40 Frames which display the picture.
  6. Now we'll create the animation for the Movie Clip instance (the oval) in the Mask Layer.
    - We'll make the oval shape to move continuously from left to right, changing also its size.
    Select the Frame 40 in the Mask Layer (Layer 2), right-click on this frame and choose Insert Frame, then click Insert -> Motion Tween.
  7. Right-click again on Frame 40 in Layer 2, and choose Insert Keyframe.
  8. Select the Frame 20 in Layer 2, move the oval to the right side of the picture, and increase its size (with the "Free Transform tool").
    Click on Frame 40 (in Layer 2) and use the "Free Transform tool" to increase the size of the oval.
  9. Right-click on the "Layer 1" name in the Timeline, and choose Properties. Then, in the "Layer Properties" window enable the Masked checkbox, and click OK.
    - The Layer 1 becomes a Masked Layer, linked to the Mask Layer above.
    Press Ctrl+Enter to view the result. Will appear a Flash presentation like this:
- In the presentation below you can watch the steps of this example.

Masking effect

mask_effect_steps
- You can download the FLA file with this example from -> Masking effect.

You can use any filled shape as a mask. Flash ignores gradients and lines, it just deals with the fill area.
You can edit the Motion Tween used for Mask as any normal Motion Tween.
You can use any type of animation in the Mask Layer (frame-by-frame, Classic Tween, or Shape Tween).

An ideea for a Masking effect is to keep fixed the shape used for the visualisation area, and move the image in the Masked Layer.
Too much masking can affect performance in the Flash Player, especially when objects are animated.


- To convert a mask layer back to a normal layer, open the "Layer Properties" window and enable the Normal checkbox.
- To remove a mask layer entirely, select it and then click the Delete Layer icon.
- To remove a linked layer from a mask layer, select it, open the "Layer Properties" window and enable the Normal checkbox.

Daily Test with Code Example

HTML
CSS
JavaScript
PHP-MySQL
Which tag is used to add lists into <ul> and <ol> elements?
<dt> <dd> <li>
<ul>
 <li>http://coursesweb.net/html/</li>
 <li>http://coursesweb.net/css/</li>
</ul>
Which value of the "display" property creates a block box for the content and ads a bullet marker?
block list-item inline-block
.some_class {
  display: list-item;
}
Which instruction converts a JavaScript object into a JSON string.
JSON.parse() JSON.stringify eval()
var obj = {
 "courses": ["php", "javascript", "ajax"]
};
var jsonstr = JSON.stringify(obj);
alert(jsonstr);    // {"courses":["php","javascript","ajax"]}
Indicate the PHP class used to work with HTML and XML content in PHP.
stdClass PDO DOMDocument
$strhtml = '<body><div id="dv1">CoursesWeb.net</div></body>';
$dochtml = new DOMDocument();
$dochtml->loadHTML($strhtml);
$elm = $dochtml->getElementById("dv1");
echo $elm->nodeValue;    // CoursesWeb.net
Creating Mask Layers in Flash

Last accessed pages

  1. Vue JS - Transition and Animation (490)
  2. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (141749)
  3. Node.js Move and Copy file (28420)
  4. MouseEvent - Events for Mouse (2909)
  5. PHPMailer (2311)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (473)
  2. CSS cursor property - Custom Cursors (79)
  3. The Mastery of Love (70)
  4. PHP-MySQL free course, online tutorials PHP MySQL code (62)
  5. CSS3 2D transforms (46)