PDA

View Full Version : onEnterFrame doesn't work for a clip loaded with loadMovie



marc0047
August 9th, 2004, 10:14 AM
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

claudio
August 9th, 2004, 11:02 AM
You have to assign the onEnterFrame after the movie is fully loaded.

RvGaTe
August 9th, 2004, 11:03 AM
make sure it has been loaded :)

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

senocular
August 9th, 2004, 11:30 AM
well "lines" is not how you should think about it ;) 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.

RvGaTe
August 9th, 2004, 11:53 AM
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 :P
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..

senocular
August 9th, 2004, 12:15 PM
hense "basically" ;)

RvGaTe
August 9th, 2004, 12:48 PM
hmm, whatever, atleast its working now i guess :P