Ok so basically your saying to flash 'hey load this movie into level2'
(now lets assume for arguments sake it take flash 3 secs to load it into level2)
But BEFORE it has even loaded.. u are saying
Code:
trace(_level2);
_level2.onEnterFrame = function(){
trace("function executed");
}
hence trying you are trying to access level2 even before it exists(before the swf has loaded into it)..hope that makes sense..
to test this theory out try this instead which will put a delay before trying to access level 2
Code:
loadMovieNum("index-new.swf", 2);
var nTimer:Number = setInterval(display, 5000);
function display(){
_level2.onEnterFrame = function(){
trace("function executed");
}
}
This will more than likely give u the result you desire(unless of course it is taking flash even more than 5 seconds to load your external swf..
however the above is just to get the point across..what u need to do is use the MovieClipLoader class instead...as this will broadcast events which will allow u to know when the swf has loaded...( look in the doicumentation for further events broadcast by this object)
e.g
Code:
var myMCL:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
myMCL.addListener(mclListener);
mclListener.onLoadInit = function(target_mc:MovieClip) {
//the swf has loaded do what u need here
trace(_level2);
//do
};
myMCL.loadClip("index-new.swf", 2);