generateWater();

This code doesnt work. I have the slightest idea why…

[AS]function generateWater(amount, size) {
for (i; i<amount; i++) {
ID = _root.createEmptyMovieClip(“water”+i, i);
ID.lineStyle(size, 0x0000FF, random(75)+25);
ID.moveTo(_xmouse, _ymouse);
ID.lineTo(_xmouse+5, _ymouse+5);
}
}
generateWater(1, 10);[/AS]

How is it supposed to work?

You could try not using “size” as input variable name, it might interfere with some built-in property name or function in Flash.

What you could also try is using the following to create the movieClip:

ID = “water” + i;
_root.createEmptyMovieClip(ID, i);
_root[ID].lineStyle(size, 0x0000FF, random(75)+25);
etcetera…

My experience is, if something doesn’t work quite right, try using variables and variable calls in every possible way to solve the problem. The above syntax is quite a safe option.

Hope this helps.

I don’t know what it’s supposed to do, but I can tell you why it isn’t doing anything at all for now: you didn’t give the variable i in the for loop a value:


function generateWater(amount, size) {
        for (i=0; i<amount; i++) {
                ID = _root.createEmptyMovieClip("water"+i, i);
                ID.lineStyle(size, 0x0000FF, random(75)+25);
                ID.moveTo(_xmouse, _ymouse);
                ID.lineTo(_xmouse+5, _ymouse+5);
        }
}
generateWater(1, 10);

Thanx Ilyas it works!

Wait… now there’s another problem. When the function is called multiple times, evrytime it is called, it just replaces the water drops with new ones. Here is the code: [AS]xoffset = 150;
yoffset = 200;
function generateWater(amount) {
for (i=0; i<amount; i++) {
id = _root.createEmptyMovieClip(“water”+i, i);
id.yspeed = random(20)+20;
id.xspeed = random(10)-5;
id.lineStyle(10, 0x0000FF, random(75)+25);
id.moveTo(xoffset, yoffset);
id.lineTo(xoffset, yoffset+1);
id.onEnterFrame = moveWater;
}
}
function moveWater() {
this._y -= this.yspeed;
this._x += this.xspeed;
this.yspeed -= 3;
}
onEnterFrame = function () {
generateWater(1);
};
[/AS]

xoffset = 150;
yoffset = 200;
cDepth = 0;
function generateWater(amount) {
        for (i=0; i<amount; i++) {
cDepth++;
                id = _root.createEmptyMovieClip("water"+cDepth, cDepth);
                id.yspeed = random(20)+20;
                id.xspeed = random(10)-5;
                id.lineStyle(10, 0x0000FF, random(75)+25);
                id.moveTo(xoffset, yoffset);
                id.lineTo(xoffset, yoffset+1);
                id.onEnterFrame = function() {
        this._y -= this.yspeed;
        this._x += this.xspeed;
        this.yspeed -= 3;
};
        }
}
generateWater(2);

Yes… thank you norie, i see the problem now.