# Calling Method Problem

**URL:** <https://forum.kirupa.com/t/calling-method-problem/22088>\
**Category:** flash\
**Created:** [May 30, 2003, 2:53am UTC](https://forum.kirupa.com/t/calling-method-problem/22088 "2003-05-30T02:53:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nigeledge](https://avatars.discourse-cdn.com/v4/letter/n/8797f3/32.png) [@nigeledge](https://forum.kirupa.com/u/nigeledge)\
**Post date:** [May 30, 2003, 2:53am UTC](https://forum.kirupa.com/t/calling-method-problem/22088/1 "2003-05-30T02:53:27Z")

</div>

I apologize if a similar question has been asked before. I searched and couldn’t find what I was looking for.

I’ve got a loop which creates some instances of a movie clip. I’m then trying to call a function from the newly created movie clip. The loop runs fine and the clips are attached… however… the function is never called. I’ve got a trace action in the method being called and it never prints. Is the syntax for calling the method incorrect? Here’s the code…  
[AS]for(i = 0;i\<imageSize;i++)  
{  
// clipname  
clipName= “imageFrame” + i;

```
    //clip depth
    clipDepth= i+10;
    
    // attach the image clip
    _root.attachMovie("image_frame",clipName,clipDepth);
    
    // call function in the new clip
    _root[clipName].loadImage();

```

}[/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:** [May 30, 2003, 3:21am UTC](https://forum.kirupa.com/t/calling-method-problem/22088/2 "2003-05-30T03:21:49Z")

</div>

Can you post the loadImage() code? I presume the loadImage() code is inside the “image\_fram” clip?

---

<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:** [May 30, 2003, 3:24am UTC](https://forum.kirupa.com/t/calling-method-problem/22088/3 "2003-05-30T03:24:13Z")

</div>

loadImage() code…

```auto
function loadImage() {
    trace("load image() called");
}

```

You are correct, it is in the image\_frame clip.

---

<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:** [May 30, 2003, 3:42am UTC](https://forum.kirupa.com/t/calling-method-problem/22088/4 "2003-05-30T03:42:19Z")

</div>

Check the attachment out. The functionClip.fla contains a function and a trace statement. The loadFunction.fla loads functionClip.swf. The trace statement from functionClip executes as soon as it loads, and then on frame 20 of loadFunction.fla I call the greeting() function from functionClip.swf (I put it on page 20 so that it has time to load, if you call it too soon, it won’t execute because the movieclip hasn’t loaded yet). The function executes properly.
