hello guys, i really hope someone can help me with this. i cannot figure this out.
I use a for loop to duplicate a few times a movie clip that i created just before. They are assigned a name each monkey1, monkey2, etc…
but then i want to move those create frame but dynamically since they will vary and i can’t write out the discrete names everytime; so it means i have to use a variable of some kind but i cannot call those movieclips back somehow.
The code sample is below, it is mainly the last 3 lines that are the issue. Thanks a lot. Cheers.
bgPatternGeneration();
function bgPatternGeneration(){
loadLocation2.createEmptyMovieClip("pattern", this.getNextHighestDepth());
loadLocation2.pattern.createEmptyMovieClip("macaque", this.getNextHighestDepth());
//this.createEmptyMovieClip("rectangle_mc", 10);
//rectangle_mc._x = 100;
//rectangle_mc._y = 100;
barNumbers=9;
barW=Math.ceil(Stage.width/barNumbers);
drawRectangle(loadLocation2.pattern.macaque, barW, 100, 0x000000, 100);
function drawRectangle(target_mc:MovieClip, boxWidth:Number, boxHeight:Number, fillColor:Number, fillAlpha:Number):Void {
with (target_mc) {
beginFill(fillColor, fillAlpha);
moveTo(0, 0);
lineTo(boxWidth, 0);
lineTo(boxWidth, boxHeight);
lineTo(0, boxHeight);
lineTo(0, 0);
endFill();
}
}
var duplicate:MovieClip;
for(var i:Number=1; i<=barNumbers;i++) {
var newX:Number=((i-1)*barW);
duplicate = loadLocation2.pattern.macaque.duplicateMovieClip("monkey"+i, i, {_x:newX});
}
//removeMovieClip(loadLocation2.pattern.macaque);
loadLocation2.pattern._height=Stage.height;
};
trace(loadLocation2.pattern.monkey3);
k=2;
bouffon="loadLocation2.pattern.monkey"+k;
//the way below doesn't work either
//bouffon=loadLocation2.pattern.monkey[k];
trace(bouffon);
bouffon._y=188;