Skip to main content
Kwangle
Known Participant
March 11, 2011
Question

Delay Between Loading a Movie and Being Able to Call its Functions

  • March 11, 2011
  • 1 reply
  • 841 views

Hi All,

I've written some code that ads a number of movie clips from the library to the stage with a loop. Each clip has a function that makes the clips visible and animates them in. Previously this works fine, I add the clips which sit on screen invisible until the activate function is called - it works fine. However, if I add the clip dynamically and call the function in the same block of code it doesn't work. I've added 'trace' code to the function being called to see if it activates but it doesn't.

I'm guessing the function doesn't become available immediately, perhaps not until the next frame and I've also noticed this problem with timeline based graphics - they have to be added a frame earlier than when a function they contain is called. Any ideas how I can solve these issues?

Here's my code:

for (i=0; i<4; i++) {

  attachMovie("nomCirMC","tCir"+i,i+500);

  targ = eval("tCir"+i);

  with(targ) {

    _x = 100*i;

    _y = 200;

    _xscale = 200;

    _yscale = 200;

    //function that makes the movie clip display - NOT WORKING

    showClip();

  }

}

Any help would be greatly appreciated - thanks!

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
March 11, 2011

i is probably don't defined correctly in showClip().  use the trace statement to confirm and test your value of targ in showClip().

Kwangle
KwangleAuthor
Known Participant
March 11, 2011

Thanks for helping but I don't really undertstand that answer, could you please clarify that?

Are you confirming that Functions can be called as soon as a clip is loaded onto the stage?

kglad
Community Expert
Community Expert
March 11, 2011

showClip() will be called as soon as that line of code executes.  what happens in showClip() is the problem.  show that code.