Can someone help turn this into a simple function that I can call when attaching a movie?
Also can you explain
[LEFT]while (this.i < 25) { this.i++;[/LEFT]
and
what exactly is if and else doing.
I understand that If (ball == ball) then the ball is made invisible but that is always true because that is the only MC on the stage and called…right? So what does the else do? I understand whats its doing but If “If” is always true then it doesn’t use else right. I know I am missing something…
[LEFT]MovieClip.prototype.particle = function () {
if (this._name == "ball") {
this._visible = false;
this.onMouseDown = function () {
this.i = 0;
};
while (this.i < 25) {
this.i++;
var rn = Math.floor (Math.random () * (300 - 25)) + 25;
this._xscale = rn;
this._yscale = rn;
this.duplicateMovieClip ("ball" + this.i, this.i);
removeMovieClip ("ball" + (this.i - 20));
updateAfterEvent ();
}
}
else {
this.x_speed *= .98;
this._alpha -= 0;
this._x += this.x_speed;
this._y += this.y_speed;
if (this._y > 450 || this._y < 0 || this._x > 750 || this._x < 0 || this._alpha <= 0) {
this.removeMovieClip ();
updateAfterEvent ();
}
}
};
[/LEFT]
The below .swf show how the movie is supposed to play. The only way I can get it to play that way is by placing a “for” statement within the MC. That is not the correct way to do it. So I would like someone help.
while (this.i < 25) {
this.i++;
I think should be
do{
this.i++
}while(this.i < 25)
is basically the same as
for( i = this.i ; i < 25 ; i++){}
or you could just do
for (;this.i < 25 ; i++) {}
all 3 of those for this case would be evaluated the same way i believe
what specific parts dont you understand and maybe i can help explain them…(that effect is pretty dmn cool btw)
did you write that nice explosion code by yourself? and yet you dont know what if/else does and what while is all about?
the while is basically saying 'do whatever actions are in my brackets until the variable i equals 24 (ie less than 25)'
on that i would probably put the “this.i++;” at the end of the actions inside the while brackets
edit: yea a for is better
for(i=0; i<25; i++) {
var rn = Math.floor(Math.random()*(300-25))+25;
this._xscale = rn;
this._yscale = rn;
this.duplicateMovieClip("ball"+this.i, this.i);
removeMovieClip("ball"+(this.i-20));
updateAfterEvent();
}
hehe yeh thats what i thought “■■■■ that effect is awesome for him not knowin wtf hes doin…” Im guessing its pilfered from somewhere…but thats a neat effect
yea my thoughts too - pilfered 
Hello,
I took some explosion code and modified it. Unfortunatly when I tried to convert it from a prototype to a simple function I could not get it to work. I am very new to flash and I am not familiar with “while” so I thought maybe I am missing something.
If you notice the code works with an onRelease but when you play the swf No Release is needed.
I added a for statement to the MC to show an example of what I needed the above code converted to.

I am guilty as charged. But I did change a few things.
Orginal code created by David Brushinski
Swf Below
movieclip.prototype.particle = function() {
if (this._name == "mc") {
this._visible = false;
this.onMouseDown = function() {
this.i = 0;
};
while (this.i<100) {
this.i++;
this.duplicateMovieClip("mc"+this.i, this.i);
}
} else {
this.x_speed*=.98;
this._alpha-=2;
this._x += this.x_speed;
this._y += this.y_speed;
if (this._y>450 || this._y<0 || this._x>750 || this._x<0||this._alpha<=0) {
this.removeMovieClip();
}
}
};
Ok I tried your code and was similar to the results I was getting.
Refer to swf below.
The movie is just looping. I am sure it has something the onMouseDown but I have tried everything to get the same swf as the one above and can never do it unless I ad a “for” statement to the MC.
Grrr.
MovieClip.prototype.particle = function () {
if (this._name == "ball") {
this._visible = false;
this.onMouseDown = function () {
this.i = 0;
};
for (i = 0; i < 25; i++) {
var rn = Math.floor (Math.random () * (300 - 25)) + 25;
this._xscale = rn;
this._yscale = rn;
this.duplicateMovieClip ("ball" + this.i, this.i);
removeMovieClip ("ball" + (this.i - 20));
updateAfterEvent ();
}
}
else {
this.x_speed *= .98;
this._alpha -= 0;
this._x += this.x_speed;
this._y += this.y_speed;
if (this._y > 450 || this._y < 0 || this._x > 750 || this._x < 0 || this._alpha <= 0) {
this.removeMovieClip ();
updateAfterEvent ();
}
}
};
and what are you trying to get it to do?
maybe your going about this wrong…why do you need to make it a function instead of a prototype?
then again im pretty new to AS too
Mainly I want to understand the code. The way it is written I can’t understand all its features and can’t recreate it. I want the movie to work just like my first post but written without the “for statment” attached to MC and “onMouseDown”
Also having trouble finding someone to explain.
For instance.
this.onMouseDown = function() {
As you can see the movie still works with it?
if (this._name == "ball") {
Ball is the only MC so that is always true.
else {
this.x_speed *= .98;
this._alpha -= 0;
this._x += this.x_speed;
this._y += this.y_speed;
if (this._y > 450 || this._y < 0 || this._x > 750 || this._x < 0 || this._alpha <= 0) {
this.removeMovieClip ();
updateAfterEvent ();
If ball is always true then “else” is never used…right?
Just loops till ball is false.
The code is neccessary because if removed nothing happens.
Just a noob trying to understand.
Here is the Fla.