I am making a screensaver from Flash.
I have 3 MC’s on the stage. Two of them are dynamically duplicated by using this code:
function WVU(){
w = 0;
while (w<25) {
//duplicateMovieClip(dot, “wvu”+i, i);
_root.wvu_mc.duplicateMovieClip(“wvu”+w, w);
w++;
//trace("WVU "+w);
}
}
function UVA(){
r = 0;
while (r<25) {
//duplicateMovieClip(dot, “uva_mc”+i, i);
_root.uva_mc.duplicateMovieClip(“uva”+r, r);
r++;
//trace("UVA "+r);
}
}
WVU();
UVA();
PROBLEM ONE:
Actually the UVA mc is not duplicating. only one appears on the stage. I traced it and it says it dupes it 25 times…I don’t know what is happening.
Next, the mc’s on the stage that are being duped have the following code attached to them (which in turn creates it on the duplicated MC’s)
onClipEvent (load) {
//data you may want to change
width = current_width;
height = current_height;
speed = Math.round(Math.random()*2)+1;
//initial positions
x = Math.random()*width;
y = Math.random()*height;
this._x = x;
this._y = y;
x_new = Math.random()*width;
y_new = Math.random()height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_xspeed;
} else {
x_new = Math.random()width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_yspeed;
} else {
y_new = Math.random()*height;
}
if (_root.wvu_mc, hitTest(_root.tech_mc)) {
unloadMovie (this);
}
}
What happens is that each duplicated MC floats across the stage and when they hit the ‘_root.tech_mc’ MC they unloadMovie and just disappear.
That works properly.
Now, I have a MC on the stage called ‘ouch_fade_mc’, which is a simple MC that has a fading tween that says ‘ouch’.
Using the MC ouch_fade_mc that exists on the stage, I added the following code to the WVU mc, which results in the ouch_fade_mc being played at the same location of the dynamic mc as it triggers the hitTest (as in, the WVU hits the Tech mc and the Tech logo makes the WVU disappear and be replaced with “ouch”.).
onClipEvent (load) {
//data you may want to change
width = current_width;
height = current_height;
speed = Math.round(Math.random()*2)+1;
//initial positions
x = Math.random()*width;
y = Math.random()*height;
this._x = x;
this._y = y;
x_new = Math.random()*width;
y_new = Math.random()height;
}
onClipEvent (enterFrame) {
//x movement
if (x_new>this._x) {
sign_x = 1;
} else {
sign_x = -1;
}
dx = Math.abs(x_new-this._x);
if ((dx>speed) || (dx<-speed)) {
this._x += sign_xspeed;
} else {
x_new = Math.random()width;
}
//y movement
if (y_new>this._y) {
sign_y = 1;
} else {
sign_y = -1;
}
dy = Math.abs(y_new-this._y);
if ((dy>speed) || (dy<-speed)) {
this._y += sign_yspeed;
} else {
y_new = Math.random()*height;
}
// THIS IS THE NEW PART THAT TRIGGERS THE "OUCH" MC
if (_root.wvu_mc, hitTest(_root.tech_mc)) {
//trace ("hurt");
_root.ouch_fade_mc._x = this._x;
_root.ouch_fade_mc._y = this._y;
_root.ouch_fade_mc.play();
unloadMovie (this);
}
}
The problem with this method is that there is only one ‘ouch_fade_mc’ and 50 MC’s that are supposed to disappear and trigger that ouch animation. so when they are triggered too rapidly they overlap and don’t fully run. I hope that makes sense.
SO, what I want to do is attachMovie from the library (ouch_fade) and have that called to the _x/_y of the WVU/UVA mc that disappears. In order to do that i need to attachMovie that has a dynamically or randomly created number at the end of it’s name, right? Now I have:
attachMovie (“ouch_fade”, “ouch_fade_mc”, 10);
if (_root.wvu_mc, hitTest(_root.tech_mc)) {
//trace (“hurt”);
attachMovie (“ouch_fade”, “ouch_fade_mc”, 10);
unloadMovie (this);
}
but nothing happens.
If anyone could help me with this code that would be great. I have attached a zip file with the FLA in is.
I simply want the VT to hit the WVU and UVA and have the ‘ouch_fade’ object called from the library and have it play its animation.
This is really hard for me to understand.
Thanks in advance.
Van