Load external swf file at a specific frame number

Hi guys i have a series of buttons with actions to load different swf files. I’m using this code:


to load files that start from the beginning. Now i want to load an external swf file to start at a specific frame number, can i use the same code? How do i specify my frame number? I still want to load the movie in the current window, you know replacing my current movie.

Thanks for the help.

i wouldn’t use the same code…because with loadmovienum there’s no way to execute actions when the loaded movie is ready to respond.

the solution is to use the movieClipLoader class. it works much the same way:

var myloader:MovieClipLoader = new MovieClipLoader();

make a new movieclipLoader, then attach a listener to it, ‘this’ refers to the root i believe, but you could attach it to any object. Now we have the moviecliploader listening for events to fire from a “load” action.

what events do you want to listen for? here’s a list:

  • .onLoadStart - fires when to initiate a ‘load’
  • .onLoadProgress - fires everytime new data is downloaded (great for using progress bars)
  • .onLoadComplete - fires when the movie has completely downloaded (but may not have initiated script on its first frame)
  • .onLoadInit - fires when the first frame has completely initiated.
  • .onLoadError - fires when the download can’t proceed.

you want the onLoadComplete or onLoadInit event. what do you want to happen when this event occurs? You want the loaded movieclip to jump to a certain frame:

myloader.onLoadComplete = function(target:MovieClip) {
	target.gotoAndPlay ("the frame you want it to go to...")

now all you have to do is use the ‘load’ method to request the download of the movieclip:

myloader.loadClip("the url where your external file is located", "the containing movieclip you want to load into");

//an arbitrary example would be like this:
myloader.loadClip("../puppy.jpg", _parent.holder_mc);

Hello Ashley, thanks for taking the time to respond in such a descriptive way. Obviously I’m not familiar with actionscript so you’ll have to excuse me, so the code i have to use would look like this?:

var myloader:MovieClipLoader = new MovieClipLoader();

myloader.onLoadComplete = function(target:MovieClip) {
target.gotoAndPlay (“250”)

myloader.loadClip(“myexternalmovie.swf”, _parent.holder_mc);

And also this code goes in the button? inside an on(release) command?

Thanks again for your answer.

the code would go a frame in the timeline. this part:

var myloader:MovieClipLoader = new MovieClipLoader();

myloader.onLoadComplete = function(target:MovieClip) {
target.gotoAndPlay ("250")

can go on any frame as long as it’s initialized before you actually call the “load” method.

this part:

myloader.loadClip("myexternalmovie.swf", _parent.holder_mc);

would also go on a frame, and when the playhead reaches that frame the externalMovie.swf is loaded in. if you place this code on the root timeline, obviously the “_parent.holder_mc” would need to change to “holder_mc” or where ever that movieclip exists in relation to the root.

You can also put that line inside a movieClip Event like onRelease, onRollOver etc. that would look like this:

myloader.loadClip("myexternalmovie.swf", this._parent.holder_mc);

which would exist on a timeline frame that also has access to the instance “my_button” (both the code and the keyframe that holds the “myButton_mc” must be on the same frame number). Then anytime the user clicks and release s on that movieclip instance, the load method is called.

hope that explains it…if you still need help try making an example fla and upload it so i can see what it is you’re doing.

Dear Ashley,

Sorry for continuing a thread after such a long time… but unfortunately I’ve stumbled on the same problem (I am also a newbie in flash and I use flash 8.0 AS2)…
I am trying to load an external swf file in a movie called film, and I would like to go to a certain frame in the swf file and not in the beginning…
I tried to use the code you suggested earlier in this thread

  1. I use this code in the first frame of the fla file, as you kindly indicated:
    [B]var myloader:MovieClipLoader = new MovieClipLoader();

myloader.onLoadComplete = function(target:MovieClip) {
target.gotoAndPlay (“210”)

Then, later on in the frame from which I insert the rest of the code you indicated:
myloader.loadClip(“compozitii.swf”, film);

When I execute it, I get this error:
[B]Error Scene=Scene 1, layer=action, frame=2:Line 4: There is no property with the name ‘onLoadComplete’.
myloader.onLoadInit = function(target:MovieClip) {

Total ActionScript Errors: 1 Reported Errors: 1[/B]

Could you be so kind to provide me with some help?

Thank you very much in advance, and please excuse the trouble…

the problem is this line: myloader.addListener(this);

somewhere along the way they upgraded the debugger to throw that error when you reference “this” you create a new object and set the reference so for this example:

var myloader:MovieClipLoader = new MovieClipLoader();
var myObj:Object;

the object can really be any object or movieclip on stage.