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 definition lists into a <dl> element?
<dt> <dd> <li>
<dl>
 <dt>HTML</dt>
  <dd> - Hyper Text Markup Language</dd>
  <dd> - Language for web pages</dd>
</dl>
Which CSS property can hide an element on page, letting an empty space in its place?
display position visibility
#id {
  visibility: hidden;
}
Click on the event which is triggered when the mouse clicks on an object.
onclick onmouseover onfocus
document.getElementById("id").onclick = function(){
  alert("http://CoursesWeb.net/");
}
Indicate the PHP variable that contains the contents of both $_GET, $_POST, and $_COOKIE arrays.
$_SESSION $_GET $_REQUEST
if(isset($_REQUEST["id"])) {
  echo $_REQUEST["id"];
}
Creating Mask Layers in Flash

Last accessed pages

  1. How to use php variable in external js file (3710)
  2. $_GET, $_POST and $_REQUEST Variables (33709)
  3. PHP getElementById and getElementsByTagName (49142)
  4. PuzzleImg - Script to Create Image Puzzle Game (9403)
  5. Integer and Float value in Select with PDO from string to numeric (8573)

Popular pages this month

  1. Courses Web: PHP-MySQL JavaScript Node.js Ajax HTML CSS (253)
  2. Read Excel file data in PHP - PhpExcelReader (91)
  3. The Four Agreements (76)
  4. PHP Unzipper - Extract Zip, Rar Archives (76)
  5. The Mastery of Love (66)
Chat
Chat or leave a message for the other users
Full screenInchide