PDA

View Full Version : Calling Method Problem



nigeledge
May 29th, 2003, 10:53 PM
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...
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();
}

aurelius
May 29th, 2003, 11:21 PM
Can you post the loadImage() code? I presume the loadImage() code is inside the "image_fram" clip?

nigeledge
May 29th, 2003, 11:24 PM
loadImage() code...

function loadImage() {
trace("load image() called");
}
You are correct, it is in the image_frame clip.

aurelius
May 29th, 2003, 11:42 PM
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.