Forum Moderators: open

Message Too Old, No Replies

_levelN.onEnterFrame not working.

Can't access/manipulate the _level

         

CtrlAltDimension

8:38 pm on May 24, 2006 (gmt 0)

10+ Year Member



I have some ActionScript in a frame that loads an external SWF onto a level and then executes a function

loadMovieNum("index-new.swf", 2);
trace(_level2);
_level2.onEnterFrame = function(){
trace("function executed");
}

Unfortunately, I can't get it to work. The SWF loads at the top-left corner of my SWF, but I can't manipulate it with ActionScript after that. The first trace comes back undefined and the onEnterFrame function doesn't even work. How can I manipulate _level2 if the player won't let me access it?

I'm using Macromedia Flash MX Professional 2004.

oxbaker

6:42 pm on May 25, 2006 (gmt 0)

10+ Year Member



dont attach event methods to a level attach them to the movie clip object.

So you loaded via loadMovieNum (which i dont like to use at all) but the fact still remains that that movie clip is not at _level2 you should be able to address it via dot notatation _level2.index-new.swf._x or something like that.

An WAY easier way to do it is this:
1) create a totally blank movie clip in your library (name it holder_mc)
2) put holder mc at the exact x and y on your stage where you want index-new.swf to reside.
3) Load index-new into holder mc with this code

//ACTIONSCRIPT
holder_mc.loadMovie("index-new.swf");

4) Now that its loaded you can reference it as if it was named holder_mc. So you can go

//move it 10 pixels left
holder_mc._x += 10;
//shrink the x and y scale
holder_mc._xscale = 50;
holder_mc._yscale = holder_mc._xscale;

hth,
mcm