-
Making mc array "explode" in all different directions when click on one mc
Please see my code below. I have a rollover and rollout effect in my for loop that affects all of the mcs in my array. But when I click on one of the mcs I want all of them to "explode" in all different directions. Obviously I would accomplish this by setting it up in my tween so that they all go in random directions. But I'm not exactly sure how to do it in my for loop. The way I have my onRelease function set up right now only makes the very last mc tween. How do I make my tween affect all of my mcs?
My code:
Code:
import com.greensock.TweenMax;
import com.greensock.easing.*;
var linkageID_array:Array = new Array();
var numRows:Number = 6;
var numColumns:Number = 8;
var counter:Number = 0;
//put linkage string references in array
for (m=1; m<49; m++) {
linkageID_array.push("pic"+m);
}
// shuffle function
shuffle = function (targetArray) {
for (i=0; i<targetArray.length; i++) {
var tmp = targetArray[i];
var randomNum = random(targetArray.length);
targetArray[i] = targetArray[randomNum];
targetArray[randomNum] = tmp;
}
};
// shuffle linkage array
shuffle(linkageID_array);
// attach mc in grid
for (k=0; k<numColumns; k++) {
for (i=0; i<numRows; i++) {
var mc:MovieClip = this.attachMovie(linkageID_array[counter], linkageID_array[counter], this.getNextHighestDepth());
counter++;
mc._x = 199*i;
mc._y = 199*k;
mc.onRollOver = function(){
mc.swapDepths(this.getNextHighestDepth);
TweenMax.from(this.pc.ovr, .2, {colorMatrixFilter:{contrast:2, brightness:1.7, colorize:0xffffff}});
}
mc.onRollOut = function(){
TweenMax.to(this.pc.ovr, .2, {colorMatrixFilter:{amount:0}});
}
mc.onRelease = function(){
TweenMax.to(mc,2, {_y:-2000, easing:Elastic.easeIn, delay:.5});
}
}
}
-
Code:
var _MAIN = this;
var maxAmt = ((Stage.width>Stage.height) ? Stage.width : Stage.height)+100;
var minAmt = -100;
for (k=0; k<numColumns; k++) {
for (i=0; i<numRows; i++) {
var mc:MovieClip = _MAIN.attachMovie(linkageID_array[counter], linkageID_array[counter], _MAIN.getNextHighestDepth());
counter++;
mc._x = 199*i;
mc._y = 199*k;
mc.onRollOver = function() {
this.swapDepths(_MAIN.getNextHighestDepth());
TweenMax.from(this.pc.ovr,0.2,{colorMatrixFilter:{contrast:2, brightness:1.7, colorize:0xffffff}});
};
mc.onRollOut = function() {
TweenMax.to(this.pc.ovr,0.2,{colorMatrixFilter:{amount:0}});
};
mc.onRelease = function() {
doPlode();
};
}
}
function doPlode() {
var xdir, ydir;
for (var j in linkageID_array) {
xdir = (Math.round(Math.random())==0) ? minAmt : maxAmt;
ydir = (Math.round(Math.random())==0) ? minAmt : maxAmt;
TweenMax.to(_MAIN[linkageID_array[j]],2,{_y:ydir, easing:Elastic.easeIn, delay:.5});
TweenMax.to(_MAIN[linkageID_array[j]],2,{_x:xdir, easing:Elastic.easeIn, delay:.5});
}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|