# Function not defined immediately after create MovieClip instance

**URL:** <https://forum.kirupa.com/t/function-not-defined-immediately-after-create-movieclip-instance/116130>\
**Category:** Uncategorized\
**Created:** [July 14, 2004, 8:58pm UTC](https://forum.kirupa.com/t/function-not-defined-immediately-after-create-movieclip-instance/116130 "2004-07-14T20:58:18Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![eclipse2k](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/eclipse2k/32/635_2.png) [@eclipse2k](https://forum.kirupa.com/u/eclipse2k)\
**Post date:** [July 14, 2004, 8:58pm UTC](https://forum.kirupa.com/t/function-not-defined-immediately-after-create-movieclip-instance/116130/1 "2004-07-14T20:58:18Z")

</div>

Hello kirupa flashers,

I create a new MovieClip, call it Somehow, and link it to the name “MyClip”, for example.  
Inside of the Clip, there must be a Function like this:

```auto
 
this.sayHello = function() { return("Hello"); } 

```

(In fact, my script should do different things, but this should be enough at first 🙂

In my root frame, i do something like that:

```auto
 
attachMovie("MyClip", "MyClip01", 1);
trace(MyClip01);
trace(MyClip01.sayHello());

```

For the first trace i get “\_level0.MyClip01”, which is correct.  
But i cant call the function sayHello(), it says: “Undefined”.  
And when i put the last line in the second frame, or as a button action, it is working, but  
this is not what i want.

The reason is, that i get a big struct object where all the information is stored about  
the Clips i have to create and how to initialize them and so on.

It LOOKS LIKE this:

```auto

for(i=1; i<=100; i++) {
 attachMovie("MyClip", "MyClip"+i, i);
 theClip = eval("MyClip"+ i);
 theClip.tellSomething(i*i);
}

```

They must be MovieClips, because the functions not only response with hello, like in the example.

So I want to create the Clip copies and call the functions in one step. This example is also not working when i put it inside of a onLoad, or onEnterFrame and so on…

And ideas? I doubt that its so difficult…

Eclipse2k
