Attach movie problem

hey you guys
well let me get straight to the problem
i finaly had the time to dowload the flashmx 2004 demo
and i tried some basic stuff on it im just wondering why this script doesnt work thanks for the help :hr:
[AS]
onEnterFrame = function(){
dot = attachMovie(“dot”,“dot”+i,i);
dot._x=Math.random()*550;
dot._y=Math.random()*400;
i++;
};
[/AS]
when i preview it just comes up as flickering dots its really wierd and it only happens when it i set it to flash 7 player.

hm… no post perhapes i am the only one experiencing this problem oh well another day another question

I would recommend using the MovieClip.getNextHighestDepth() method… Like this:

[AS]
onEnterFrame = function(){
dot = attachMovie(“dot”,“dot”+i,this.getNextHighestDepth());
dot._x=Math.random()*550;
dot._y=Math.random()*400;
i++;
}
[/AS]

I was thinking about this while working on something else (real work :), and realized that I gave you bad advice.

Anyway, what I posted will give you visually what you were expecting I think, but it’s not actually right.

You’re assuming that the variable i is stepping, when it actually hasn’t been initialized.

What you’d need to do (if you REALLY need to dynamically name the instances) would be this:


onEnterFrame = function(){
        if (i==undefined) i = 0;
        dot = attachMovie("dot","dot"+i,this.getNextHighestDepth());
        dot._x=Math.random()*550;
        dot._y=Math.random()*400;
        i++;
}

But really, unless the instances have properties or methods you need to access, you can just use “dot” or any other text for that matter.

Anyway, sorry to mislead.

oh i get it soo if “i” is undefined it wont work heh flash 7 player is crazy.
BTW thanks for the help man.

No problem at all!

but why wont it just accept “undefined” as 0 like flash player 6
i liked that bug cause im lazy and a poor speller