onEnterFrame doesn't work for a clip loaded with loadMovie

I haven’t been able to find documentation on why loaded movies via
‘loadMovie’ into another movie clip don’t seem to obey onEnterFrame
commands. The following code represents a movie clip, ‘container’,
which has a loaded external .swf file, ‘box.swf’.

I have set the container to begin a decreasing alpha change. I’ve also
added a trace to see if the onEnterFrame is performing at all. What
happens is that the box does not appear to have an alpha change. There
is, however, a trace that returns an output of ‘100’ only. But no
other numbers, suggesting that the command has stopped.

// Start

container.loadMovie(“box.swf”);
container.onEnterFrame = function () {
trace(container._alpha);
container._alpha -= 1;
}

// End

You have to assign the onEnterFrame after the movie is fully loaded.

make sure it has been loaded :slight_smile:

flash can never load a clip in 1 line of code, it needs like, 10 lines to load up…

just use:


container.onLoad = function(){
container.onEnterFrame = function () {
trace(container._alpha);
container._alpha -= 1;
}
}

so it will assign the code when it has been loaded…

should work

well “lines” is not how you should think about it :wink: its more a matter of “time”. All lines of code that are to be run are basically run in one instance of time (though still maintaining order). A loaded movie cannot load and be accessible in that single instant.

lines of code that are to be run are basically run in one instance of time

not really true…

when executing a set of lines, it DOES goes in a few 0.00001 second or so :stuck_out_tongue:
this problem can also be fixed when you just give it a few extra lines… or assign it onLoad…

i think of it as lines, it can be both, just like you prefer…

hense “basically” :wink:

hmm, whatever, atleast its working now i guess :stuck_out_tongue: