View Full Version : Applying setMask to one level but not other ones below
orlando2004
December 1st, 2004, 03:31 PM
I am using the following code to generate a television unit that will load in various SWF files and obviously, I want to mask the viewing area of the television ONLY. The SWF is loaded on level 4, while the panel and buttons appear on lower levels. Problem is when I attach a mask from the library to the movieclip containing the SWF, nothing happens.
Here is my code...whats wrong with my final section (MASK)????
//create empty movieclips to hold contents:
//***** DYNAMIC PANEL - Level 1 *****
myExpanded = this.createEmptyMovieClip("expandedContainer", 1);
expandedContainer.attachMovie("expandedPanel", "expanded_mc", 1)
//***** TINT - Level 2 *****
myTint = this.createEmptyMovieClip("tintContainer", 2);
tintContainer.attachMovie("rectangle", "tint_mc", 2, {_x:PaneX, _y:PaneY, _width:PaneWidth, _height:PaneHeight});
//***** DYNAMIC TITLE - Level 3 *****
myTitle = this.createEmptyMovieClip("titleContainer", 3)
titleContainer.attachMovie("title_eforms", "eforms_mc", 3, {_x: 6, _y:1});
//***** LOAD MOVIE - Level 4 *****
myMovie = this.createEmptyMovieClip("movieContainer", 4)
movieContainer.loadMovie("d_index.swf", 4);
movieContainer._x=PaneX;
movieContainer._y=PaneY;
//***** CREATE MASK AND ATTACH IT TO TARGET CLIP
myMovie.attachMovie("tempMask", "moviemask_mc", 5, {_x:PaneX, _y:PaneY, _width:PaneWidth, _height:PaneHeight});
//use setMask to provide the viewable area of the container, NOT THE CONTENT
myMovie.setMask(moviemask_mc);
stringy
December 1st, 2004, 04:09 PM
I am using the following code to generate a television unit that will load in various SWF files and obviously, I want to mask the viewing area of the television ONLY. The SWF is loaded on level 4, while the panel and buttons appear on lower levels. Problem is when I attach a mask from the library to the movieclip containing the SWF, nothing happens.
Here is my code...whats wrong with my final section (MASK)????
//create empty movieclips to hold contents:
//***** DYNAMIC PANEL - Level 1 *****
myExpanded = this.createEmptyMovieClip("expandedContainer", 1);
expandedContainer.attachMovie("expandedPanel", "expanded_mc", 1)
//***** TINT - Level 2 *****
myTint = this.createEmptyMovieClip("tintContainer", 2);
tintContainer.attachMovie("rectangle", "tint_mc", 2, {_x:PaneX, _y:PaneY, _width:PaneWidth, _height:PaneHeight});
//***** DYNAMIC TITLE - Level 3 *****
myTitle = this.createEmptyMovieClip("titleContainer", 3)
titleContainer.attachMovie("title_eforms", "eforms_mc", 3, {_x: 6, _y:1});
//***** LOAD MOVIE - Level 4 *****
myMovie = this.createEmptyMovieClip("movieContainer", 4)
movieContainer.loadMovie("d_index.swf", 4);
movieContainer._x=PaneX;
movieContainer._y=PaneY;
//***** CREATE MASK AND ATTACH IT TO TARGET CLIP
myMovie.attachMovie("tempMask", "moviemask_mc", 5, {_x:PaneX, _y:PaneY, _width:PaneWidth, _height:PaneHeight});
//use setMask to provide the viewable area of the container, NOT THE CONTENT
myMovie.setMask(moviemask_mc);
A couple of potential problems
The path to your mask is wrong, try
movieContainer.setMask(movieContainer.moviemask_mc )
You also need to make sure content is loaded before you mask.
orlando2004
December 1st, 2004, 05:51 PM
A couple of potential problems
The path to your mask is wrong, try
movieContainer.setMask(movieContainer.moviemask_mc )
You also need to make sure content is loaded before you mask.Hi Stingy,
Thanks for responding. However, I tried changing the path and it still doesnt work. I suspect it may be because the content is not loaded before I mask??? Mind you there will be a preloader at the beginning of the external SWF so I dont want it that SWF to be masked only once it is fully loaded! Know what I mean? I also read a few threads and began wondering if maybe I need to put my levels(or depths) 1-3 in ONE movieclip instead?
Any thoughts?
stringy
December 1st, 2004, 06:11 PM
Hi Stingy,
Thanks for responding. However, I tried changing the path and it still doesnt work. I suspect it may be because the content is not loaded before I mask??? Mind you there will be a preloader at the beginning of the external SWF so I dont want it that SWF to be masked only once it is fully loaded! Know what I mean? I also read a few threads and began wondering if maybe I need to put my levels(or depths) 1-3 in ONE movieclip instead?
Any thoughts?
I think you would be better not trying to mask with an attached clip
try something like this
myMovie = this.createEmptyMovieClip("movieContainer", 4);
movieContainer.loadMovie("whatever.swf");
myInterval = setInterval(preloadf, 50);
//you could make this only _visible after preload
_root.attachMovie("tempMask", "moviemask_mc", 5);
function preloadf() {
if (movieContainer._width>0) {
clearInterval(myInterval);
movieContainer.setMask(_root.moviemask_mc);
}
}
orlando2004
December 1st, 2004, 06:35 PM
I think you would be better not trying to mask with an attached clip
try something like this
myMovie = this.createEmptyMovieClip("movieContainer", 4);
movieContainer.loadMovie("whatever.swf");
myInterval = setInterval(preloadf, 50);
//you could make this only _visible after preload
_root.attachMovie("tempMask", "moviemask_mc", 5);
function preloadf() {
if (movieContainer._width>0) {
clearInterval(myInterval);
movieContainer.setMask(_root.moviemask_mc);
}
}
I will try your code. Thanks. But just to clarify,are you saying that I should keep my x=this.createEmptyMovieClip lines for my different elements? What is the advantage of putting all my attachMovies inside their own empty movie clip instances?
stringy
December 2nd, 2004, 07:50 AM
I will try your code. Thanks. But just to clarify,are you saying that I should keep my x=this.createEmptyMovieClip lines for my different elements? What is the advantage of putting all my attachMovies inside their own empty movie clip instances?
none that i can think of.
You don`t need all the empty movie clips, just one to load into.
orlando2004
December 2nd, 2004, 10:28 AM
none that i can think of.
You don`t need all the empty movie clips, just one to load into.Hi Stringy! Ok, its the first time I use Actionscript so extensively so I do have a few questions... First, why does my mask only work when we put it at the root level? Second, why does it only work by setting up a function such as the one you created? And third, if I want to add a scrollbar to the swf I am loading in, do I target the myMovie or the movieContainer?
Thanks in advance
orlando
stringy
December 2nd, 2004, 11:15 AM
Hi Stringy! Ok, its the first time I use Actionscript so extensively so I do have a few questions... First, why does my mask only work when we put it at the root level? Second, why does it only work by setting up a function such as the one you created? And third, if I want to add a scrollbar to the swf I am loading in, do I target the myMovie or the movieContainer?
Thanks in advance
orlando
it won`t only work at _root level, you could attach to another movieclip but i don`t think you can attach to the container you are loading into. I just thought this was the most simple way to do it. If you changed the code to
this.attachMovie("tempMask", "moviemask_mc", 5); - it would work on any timeline.
You can only mask a movie once it is fully loaded and that is what the function does- checks if loaded.
I don`t use the mm scrollbars but i would imagine either will do.If you want to be safe just use movieContainer.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.