-
for - duplicate prob
we all know about the ol for loop with duplicateMovie in it, right,... so anyway, how do you make it work!?!
my code should be like this:
code:
function Emits() {
for (j=0; j<=7; j++) {
duplicateMovieClip("emitter", "emitter"+j, j);
a = (_root.Starter._y-_root.Ender._y)/(_root.Starter._x-_root.Ender._x);
b = _root.Starter._y-_root.Starter._x*a;
if (_root.Starter.invert == false) {
_root["emitter"+i]._x = random(_root.Ender._x-_root.Starter._x)+_root.Starter._x;
}
if (_root.Starter.invert == true) {
_root["emitter" + i]._x = random(_root.Starter._x-_root.Ender._x)+_root.Ender._x;
}
_root["emitter"+i]._y = a*_root["emitter"+i]._x+b;
}
but that doesn't work!
however, this does:
code:
function Emits() {
for (j=0; j<=7; j++) {
duplicateMovieClip(emitter, emitter+j, j);
a = (_root.Starter._y-_root.Ender._y)/(_root.Starter._x-_root.Ender._x);
b = _root.Starter._y-_root.Starter._x*a;
if (_root.Starter.invert == false) {
_root.emitter._x = random(_root.Ender._x-_root.Starter._x)+_root.Starter._x;
}
if (_root.Starter.invert == true) {
_root.emitter._x = random(_root.Starter._x-_root.Ender._x)+_root.Ender._x;
}
_root.emitter._y = a*_root.emitter._x+b
}
i'm afraid that it will create probs, so where did i go wrong! (btw, i'm using 2004).
thanks in advance!
Last edited by Wolf Thunder; 01-09-2004 at 09:44 AM.
-
Senior Member
Comments need // in front of them. otherwise they are seen as code.
-
woops... but thats not the problem, it's written ok i just wanted to erase the comments in this post, and flash doesn't tell me there's a syntax mistake, it just doesn't do what it's supposed to.
-
Senior Member
You also forgot a lot of " characters that are present in the first code. You need those.Otherwise Flash will think they are variables.
-
I know, that's exactly the problem... for some reason the one that's supposed to be wrong works
-
Senior Member
Its hard to say as i dont really know what the code does.
-
the code duplicates a MC called emitter 8 times, then calculates a linear function between two MCs called starter and ender (the invert var is for error handling if the user flippes the location of starter and ender) and then spreades the duplicated emitters randomly on the imagenery line between starter and ender
-
Senior Member
I get the duplication, but was not shure about the other part. Well , its strange.
-
Re: for - duplicate prob
Originally posted by Wolf Thunder
we all know about the ol for loop with duplicateMovie in it, right,... so anyway, how do you make it work!?!
my code should be like this:
code:
function Emits() {
for (j=0; j<=7; j++) {
duplicateMovieClip("emitter", "emitter"+j, j);
...
_root["emitter"+i]._y = a*_root["emitter"+i]._x+b;
}
This first code uses
_root["emitter"+i] ... but what is the i ?? Shouldn't that be _root["emitter"+j]? If not, you're missing the declaration of i
-
thanks! I can't belive I keep doing these stupid mistakes, I forgot when i added some code I changed it from i to j.
(thank you! thank you! thank you!)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|