Skip to main content
AttaBoy2
Inspiring
August 1, 2009
Answered

Need to apply a mask to loaded swf

  • August 1, 2009
  • 1 reply
  • 1116 views

this is what I need to fix:  http://mespinach.com/needmask/

this is my code I've been looking all over for an example of setting a mask using AS2

I have a container MovieClip I create dynamically I've tried to attach a movieclip to the container then set mask before loading the swf

I would like to know how to dynamically generate a mask or use a symbol from the library or stage if need be whatever works.

This is my code.

var container:MovieClip = createEmptyMovieClip("container", 3);
var mcLoader:MovieClipLoader = new MovieClipLoader();

mcLoader.addListener(this);
mcLoader.loadClip("slideshow.swf", container);


function onLoadInit(mc:MovieClip) {
    container._width = 600;
    container._height = 400;
    container._x = 200;
    container._y = 100;
}

This topic has been closed for replies.
Correct answer webqaflash

function onLoadInit(mc:MovieClip) {
    container._width = 600;
    container._height = 400;
    container._x = 200;
    container._y = 100;

     var r:MovieClip = createEmptyMovieClip("rectangles", 2);
    r.beginFill(0xcc00cc, 100);
    r.moveTo(20, 20);
    r.lineTo(160, 20);
    r.lineTo(160, 160);
    r.lineTo(20, 160);
    container.setMask(r);
}

change the values as your need.

1 reply

webqaflash
webqaflashCorrect answer
Inspiring
August 1, 2009

function onLoadInit(mc:MovieClip) {
    container._width = 600;
    container._height = 400;
    container._x = 200;
    container._y = 100;

     var r:MovieClip = createEmptyMovieClip("rectangles", 2);
    r.beginFill(0xcc00cc, 100);
    r.moveTo(20, 20);
    r.lineTo(160, 20);
    r.lineTo(160, 160);
    r.lineTo(20, 160);
    container.setMask(r);
}

change the values as your need.

AttaBoy2
AttaBoy2Author
Inspiring
August 1, 2009

When I tried that after the swf load as in your example nothing happened.  When I tried after container was created and before the swf was loaded I got a purple rectangle to the right of the swf.