# attachMovie does not attach!

**URL:** https://forum.kirupa.com/t/attachmovie-does-not-attach/25870
**Category:** flash
**Created:** [July 17, 2003, 5:42am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870 "2003-07-17T05:42:48Z")
**Posts on this page:** 14
**Page:** 1

<div class="post-metadata">

### Author: ![javadi82](https://avatars.discourse-cdn.com/v4/letter/j/3be4f8/32.png) [@javadi82](https://forum.kirupa.com/u/javadi82)
#### Post date: [July 17, 2003, 5:42am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/1 "2003-07-17T05:42:48Z")

</div>

This actionscript for “attaching” five balls refuses to work! Why?

for(i=0;i\<5;i++){  
balls=attachMovie(“aball”,“b1”+i,i);  
balls.\_x=100+i;  
balls.\_y=100+i;  
}  
Note:aball is the linkage name of the movieclip.

---

<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: [July 17, 2003, 5:55am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/2 "2003-07-17T05:55:13Z")

</div>

wow you posted 3 topics at the same time…can i see the fla?

---

<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: [July 17, 2003, 6:45am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/3 "2003-07-17T06:45:34Z")

</div>

for(i=0;i\<5;i++){  
[COLOR=red]balls=attachMovie(“aball”,“b1”+i,i);[/COLOR]  
balls.\_x=100+i;  
balls.\_y=100+i;  
}

you must change it to:  
[COLOR=red]balls.attachMovie(“aball”,“b1”+i,i);[/COLOR]

e.s.x.s

---

<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: [July 17, 2003, 7:06am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/4 "2003-07-17T07:06:12Z")

</div>

I don’t think that’s the problem, esxs. :-\

There are methods that return an Object, attachMovie returns the newly attached MovieClip (or any Symbol you attached). It’s like writing **this[“b1”+i]** so you understand… 😉

What I think, is that it’s actually working, but you need to change these lines:  
[AS]balls.\_x = 100+i;  
balls.\_y = 100+i;[/AS]  
to:  
[AS]balls.\_x = 100_i;  
balls.\_y = 100_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: [July 17, 2003, 7:33am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/5 "2003-07-17T07:33:47Z")

</div>

balls=attachMovie(“aball”,“b1”+i,i);  
if u run the code like above,it will don’t work.because the attachMovie method don’t has a property like that…

for(i=0;i\<5;i++){  
balls.attachMovie(“aball”,“b1”+i,i);  
balls.\_x=100+i;  
balls.\_y=100+i;  
}  
above code is true,but if u run this code u can’t see five balls definetely.because the balls are very close to each other…if u change the code to kode’s said:  
for(i=0;i\<5;i++){  
balls.attachMovie(“aball”,“b1”+i,i);  
balls.\_x=100_i;  
balls.\_y=100_i;  
}  
the result not changes, because u change the main MovieClip’s x and y coordinates. if you want to see the five balls exactly,u must change the code to:  
for(i=0;i\<5;i++){  
balls.attachMovie(“aball”,“b1”+i,i);  
balls[“b1”+i].\_x=100_i;  
balls[“b1”+i].\_y=100_i;  
}

thx to kode for the idea…

e.s.x.s

---

<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: [July 17, 2003, 7:49am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/6 "2003-07-17T07:49:51Z")

</div>

That’s funny, I could swear that MovieClip.attachMovie returns an Object. Just tested it and you’re right. thanks. =)

BTW, if you want to make things even easier, you could take advantage of the initObject parameter… 😉  
[AS]attachMovie(“aball”, “b1”+i, i, {\_x:100_i, \_y:100_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: [July 17, 2003, 7:58am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/7 "2003-07-17T07:58:25Z")

</div>

yeah,  
the initObject keeps the code shorter and easier to understand 😉

---

<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: [July 17, 2003, 11:30am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/8 "2003-07-17T11:30:49Z")

</div>

i checked with the explanation of attachMovie in the Help section of Flash MX and it said that attachMovie did not “return” anything.

proof:myMovieClip.attachMovie( idName, newName, depth [, initObject] )  
Returns:Nothing.

---

<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: [July 17, 2003, 11:33am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/9 "2003-07-17T11:33:51Z")

</div>

exactly! … 😉

---

<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: [July 17, 2003, 11:50am UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/10 "2003-07-17T11:50:55Z")

</div>

then how does

balls=attachMovie() work, when attachMovie() does not return anything!

---

<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: [July 17, 2003, 12:04pm UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/11 "2003-07-17T12:04:11Z")

</div>

in your code “balls” is only gives you the  
\_level0.b11, \_level0.b12, \_level0.b13 …  
but this isn’t means that the attachMovie() code runs correct.  
and this is not what u want to do. u want to attach movies in the balls movieClip i think. With your code, u attach your movies into the \_root movieClip…

e.s.x.s

---

<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: [July 17, 2003, 3:41pm UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/12 "2003-07-17T15:41:57Z")

</div>

> _Originally posted by javadi82_  
> **i checked with the explanation of attachMovie in the Help section of Flash MX and it said that attachMovie did not “return” anything.**

It doesn’t say anything for MovieClip.createEmptyMovieClip either, althought this method **does** return the MovieClip created. 😛

**EDIT.** I checked it again, MovieClip.attachMovie **DOES** return the MovieClip too.

---

<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: [July 18, 2003, 1:02pm UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/13 "2003-07-18T13:02:08Z")

</div>

To kode:

Stupid question but anyway:How did you check that attachMovie returns an object.

More stupid question:Can we tell Macromedia to change the documentation(Flash help)?

---

<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: [July 18, 2003, 1:06pm UTC](https://forum.kirupa.com/t/attachmovie-does-not-attach/25870/14 "2003-07-18T13:06:59Z")

</div>

[AS]trace(this.attachMovie(“someID”, “someInstance”, someDepth));[/AS]  
You could contact them, I don’t think they will change it though. 😛
