hello there,
i have 10 pics on the stage and i need to give them random movement and swepdepth for each image when i rollover.
my problem is that the random movement stop on the start this is my code:
onClipEvent (load) {
numOfImages = 10;
acceleration = 10;
ranx = new Array();
rany = new Array();
newpos = function (i) {
ranx* = Math.round((Math.random()*250));
rany* = Math.round((Math.random()*150));
};
for (i=1; i<(numOfImages+1); i++) {
newpos(i);
}
_root.img1.onRollOver = function() {
_root.img1.swapDepths(_root.getNextHighestDepth());
};
_root.img2.onRollOver = function() {
_root.img2.swapDepths(_root.getNextHighestDepth());
};
_root.img3.onRollOver = function() {
_root.img3.swapDepths(_root.getNextHighestDepth());
};
_root.img4.onRollOver = function() {
_root.img4.swapDepths(_root.getNextHighestDepth());
};
_root.img5.onRollOver = function() {
_root.img5.swapDepths(_root.getNextHighestDepth());
};
_root.img6.onRollOver = function() {
_root.img6.swapDepths(_root.getNextHighestDepth());
};
_root.img7.onRollOver = function() {
_root.img7.swapDepths(_root.getNextHighestDepth());
};
_root.img8.onRollOver = function() {
_root.img8.swapDepths(_root.getNextHighestDepth());
};
_root.img9.onRollOver = function() {
_root.img9.swapDepths(_root.getNextHighestDepth());
};
_root.img10.onRollOver = function() {
_root.img10.swapDepths(_root.getNextHighestDepth());
};
}
onClipEvent (enterFrame) {
for (i=1; i<(numOfImages+1); i++) {
_root['img'+i]._x += ((ranx*-_root['img'+i]._x)/acceleration);
_root['img'+i]._y += ((rany*-_root['img'+i]._y)/acceleration);
if (Math.round(_root['img'+i]._x) == ranx* || Math.round(_root['img'+i]._y) == rany*) {
newpos(i);
}
}
}