# Attach movie problem

**URL:** https://forum.kirupa.com/t/attach-movie-problem/35165
**Category:** Uncategorized
**Created:** [November 11, 2003, 4:40am UTC](https://forum.kirupa.com/t/attach-movie-problem/35165 "2003-11-11T04:40:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Booyaka](https://avatars.discourse-cdn.com/v4/letter/b/4af34b/32.png) [@Booyaka](https://forum.kirupa.com/u/Booyaka)
#### Post date: [November 11, 2003, 4:40am UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/1 "2003-11-11T04:40:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 11, 2003, 6:49am UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/2 "2003-11-11T06:49:33Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2003, 7:22pm UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/3 "2003-11-12T19:22:30Z")

</div>

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]

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 12, 2003, 9:28pm UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/4 "2003-11-12T21:28:08Z")

</div>

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:

```auto

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.

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2003, 2:57am UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/5 "2003-11-13T02:57:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 13, 2003, 1:53pm UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/6 "2003-11-13T13:53:44Z")

</div>

No problem at all!

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [November 14, 2003, 11:34pm UTC](https://forum.kirupa.com/t/attach-movie-problem/35165/7 "2003-11-14T23:34:00Z")

</div>

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