Hello, is there a way to:
- create an empty movieclip (zone1)
- create a movieclip in zone1 (zone1.contentMC)
- create an empty mask movieclip in zone1 (zone1.maskMC)
- draw a filled rectangle into zone1.maskMC
- set the zone1.maskMC as the mask for zone1.contentMC
- load content at any time into zone1.contentMC
I just spent 15 minutes putting together a post only to have it say I was not logged in (session timeout I guess)… lost the post data on backspace. Here is the code I’m working with… as you can see with the comments I’ve been at this for a while. I want to iterate through zone array… setup empty movies… then a contents and mask movie inside each movie, draw a rectangle in the mask movie and then set the mask before I put contents into the content MC.
stop();
var colorArray:Array = new Array("0xFF0000", "0x0000FF", "0x00FF00");
function drawRec(endX, endY, targetMovie:MovieClip) {
trace("drawing a mask in "+targetMovie+" with "+endX+", "+endY);
rndColor = Math.round(2*Math.random());
targetMovie.beginFill(colorArray[rndColor], 100);
targetMovie.moveTo(0, 0);
targetMovie.lineTo(endX, 0);
targetMovie.lineTo(endX, endY);
targetMovie.lineTo(0, endY);
targetMovie.lineTo(0, 0);
targetMovie.endFill();
}
function makeZones() {
atZone = 0;
for (zones in zoneArray) {
// create zone movie
this.createEmptyMovieClip("zone"+atZone, this.getNextHighestDepth());
// move new zone to it's correct x and y
this["zone"+atZone]._x = zoneArray[zones][0];
this["zone"+atZone]._y = zoneArray[zones][1];
// create contentMC
this["zone"+atZone].createEmptyMovieClip("contentMC",1 );
trace(this["zone"+atZone].contentMC);
// create Mask
this["zone"+atZone].createEmptyMovieClip("maskMC", 2);
trace(this["zone"+atZone].maskMC);
//draw Mask
drawRec(zoneArray[zones][2], zoneArray[zones][3], this["zone"+atZone].maskMC);
contentMC.setMask(maskMC);
loadMovie("images/0.jpg", contentMC);
//set the mask for the zones contentMC
atZone++;
}
}
var zoneArray:Array = new Array();
zoneArray[0] = (Array(0, 0, 250, 250));
zoneArray[1] = (Array(250, 0, 500, 250));
zoneArray[3] = (Array(0, 250, 500, 500));
//trace(zoneArray[0][0]);
makeZones();