Lets say I have two dots...a red and a blue...and I want the red to duplicate and swarm around the blue...and when it touches the blue...is destroyed(I have it move to like _x = 10000) and the blue's size diminishes when touched. When I use the for() loop...it copies the red dots...but they do not act the same..the all follow the blue..but only the origonal red dot has any effect...this is the code I'm using:
Inside of the movie clip blue:
Code:
onClipEvent(enterFrame){
bSpeed = 3;
if(Key.isDown(Key.SPACE)){
bSpeed = 8;
}
if(Key.isDown(Key.DOWN)){
_y += bSpeed;
}
if(Key.isDown(Key.LEFT)){
_x -= bSpeed;
}
if(Key.isDown(Key.UP)){
_y -= bSpeed;
}
if(Key.isDown(Key.RIGHT)){
_x += bSpeed;
}
}
Inside of the red I have :
Code:
onClipEvent(load){
this._x = Math.random()*550;
this._y = Math.random()*400;
}
onClipEvent(enterFrame){
with(_root.red){
rSpeed = 4;
if(this._y > _root.blue._y){
this._y -= rSpeed;
}
if(this._y < _root.blue._y){
this._y += rSpeed;
}
if(this._x > _root.blue._x){
this._x -= rSpeed;
}
if(this._x < _root.blue._x){
this._x += rSpeed;
}
if(_root.blue.hitTest(getBounds(_root).xMax, _y,true)){
_root.blue._height -= 5;
_root.blue._width -= 5;
_root.red._visible = 0;
_root.red._x = 10000;
}
if(_root.blue.hitTest(getBounds(_root).xMin, _y,true)){
_root.blue._height -= 5;
_root.blue._width -= 5;
_root.red._visible = 0;
_root.red._x = 10000;
}
if(_root.blue.hitTest(_x, getBounds(_root).yMax, true)){
_root.blue._height -= 5;
_root.blue._width -= 5;
_root.red._visible = 0;
_root.red._x = 10000;
}
if(_root.blue.hitTest(_x, getBounds(_root).yMin, true)){
_root.blue._height -= 5;
_root.blue._width -= 5;
_root.red._visible = 0;
_root.red._x = 10000;
}
}
}
and on the frame and layer that have the red dot I have:
Code:
for(var i=0;i<10;i++){
red.duplicateMovieClip("red",i);
}
Can someone tell me why the duplicated red dots wont' affect the blue dot?