scc
07-29-2007, 11:23 AM
Hi I wonder if anyone's got any decent solutions to this...
Basically whenever I have a script generating an interface by dynamically placing movie clips (using the attachMovie method), I often need the actionscript of the attached movie clip to execute before the rest of the code in the main script continues.
According to normal actionscript execution order, the current script finishes before 1st frame actionscript of any attached movies is executed, so say for example I had the following in frame 1 of my root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
trace("end");
and the movie clip in my library with the linkage identifier "myMovieClip" has the following on frame 1 of its timeline:
trace("middle");
Normally this would output:
start
end
middle
However I want it to output:
start
middle
end
The only appropriate way I've found so far to do this is to have a function that is called on completion of the myMovieClip actions, i.e. in the root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
movieClip1.onLoaded=function() {
trace("end");
}
and in the timeline of the myMovieClip movie clip:
trace("middle");
this.onLoaded();
But the problem with this is that if I rather than the trace("end"); statement I want a series of other commands, some of them in turn using attachMovie methods, again wanting the scripts to execute in the order above, I'm going to end up with a lot of nested onLoaded functions and it's going to end up looking pretty ugly!
Any thoughts?
Basically whenever I have a script generating an interface by dynamically placing movie clips (using the attachMovie method), I often need the actionscript of the attached movie clip to execute before the rest of the code in the main script continues.
According to normal actionscript execution order, the current script finishes before 1st frame actionscript of any attached movies is executed, so say for example I had the following in frame 1 of my root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
trace("end");
and the movie clip in my library with the linkage identifier "myMovieClip" has the following on frame 1 of its timeline:
trace("middle");
Normally this would output:
start
end
middle
However I want it to output:
start
middle
end
The only appropriate way I've found so far to do this is to have a function that is called on completion of the myMovieClip actions, i.e. in the root timeline:
trace("start");
this.attachmovie("myMovieClip","movieClip1",this.getNextHighestDepth());
movieClip1.onLoaded=function() {
trace("end");
}
and in the timeline of the myMovieClip movie clip:
trace("middle");
this.onLoaded();
But the problem with this is that if I rather than the trace("end"); statement I want a series of other commands, some of them in turn using attachMovie methods, again wanting the scripts to execute in the order above, I'm going to end up with a lot of nested onLoaded functions and it's going to end up looking pretty ugly!
Any thoughts?