A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: [RESOLVED] [F8] a setMask that does not work.

  1. #1
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    Location
    France
    Posts
    148

    resolved [RESOLVED] [F8] a setMask that does not work.

    I am trying to mask elements so that you can not see them when they go out of the scene (sounds silly like that, but no when the swf is to be loaded into another one), but somehow I can not set the mask.
    Could someone take a look at this code?
    Code:
    attachMovie("thing","masker",690);
    masker._x = 370;
    masker._y = 0;
    masker._width = 64;
    masker._height = ht;
    //
    for (i=0; i<nPics; i++) {
    	var a:MovieClip = attachMovie("thing", "mini"+i, 200+i);
    	a._x = masker._x;
    	a._y = 20+80*i;
    	a.loadMovie("img/pictures/"+i+"s.jpg");
    	//////////
    	a.setMask(masker);
    }
    I also tried setting the mask directly to one movie clip, mini2.setMask(masker); but it was as useless as a Britney Spears CD for someone lost in the Pacific Ocean.

  2. #2
    Senior Member dlowe93's Avatar
    Join Date
    Aug 2001
    Location
    Stumptown
    Posts
    621
    Quote Originally Posted by Ovaire d'Oz
    I am trying to mask elements so that you can not see them when they go out of the scene (sounds silly like that, but no when the swf is to be loaded into another one), but somehow I can not set the mask.
    Could someone take a look at this code?
    Code:
    attachMovie("thing","masker",690);
    masker._x = 370;
    masker._y = 0;
    masker._width = 64;
    masker._height = ht;
    //
    for (i=0; i<nPics; i++) {
    	var a:MovieClip = attachMovie("thing", "mini"+i, 200+i);
    	a._x = masker._x;
    	a._y = 20+80*i;
    	a.loadMovie("img/pictures/"+i+"s.jpg");
    	//////////
    	a.setMask(masker);
    }
    I also tried setting the mask directly to one movie clip, mini2.setMask(masker); but it was as useless as a Britney Spears CD for someone lost in the Pacific Ocean.
    You can't mask multiple clips with the same mask. You will either need to create separate masks for each clip, or create a "master" container and mask that. For example:

    PHP Code:
    createEmptyMovieClip("holder"680);
    attachMovie("thing","masker",690);

    holder.370;
    holder.0;

    masker._x 370;
    masker._y 0;

    masker._width 64;
    masker._height ht;
    holder.setMask(masker);
    //
    for (i=0i<nPicsi++) {
        var 
    a:MovieClip holder.attachMovie("thing""mini"+i200+i);
        
    a._x masker._x;       //keep in mind that a._x and a._y are now relative to holder, not the main clip;
        
    a._y 20+80*i;
        
    a.loadMovie("img/pictures/"+i+"s.jpg");
        
    //////////
        //a.setMask(masker);     //you don't need this now;

    Hope this helps.

    d.
    dlowe93

  3. #3
    Senior Member Ovaire d'Oz's Avatar
    Join Date
    May 2006
    Location
    France
    Posts
    148
    [ok]
    It works fine! I had to modify a couple of things in the rest of the code because this modification had incidence, but it looks perfect now. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center