Calling a function from a loaded .swf

I have a movie (let’s call it index.swf) that has a movie clip loader which is loading external .swfs Is there any way that I can call a function that is on the index.swf’s main timeline from one of the externally loaded .swfs? Basically all I want to do is to be able to play another mc that is on the index.swf’s main time line by pressing a button that is on one of the external swfs.

Hey, I’m not 100% sure I understand (its late and I’ve been coding all day and all night last night). Anyway, sounds like you have a main file and a movie clip on it (we’ll call it main_clip). Then it sounds like you loaded an external file into it and want a link from that external file to play in main_clip, replacing the external clip you are currently playing?

IF that’s the case, I believe you can do a simple:

_root.main_clip.loadMovie(“yourfile.swf”);

If my being tired has confused me, when you load a swf into another SWF’s movie clip, the main clip becomes the overall “root.” If you wanted to break this in the future and have the secondary clip be root for all the actions, you would put the code: this._lockroot=true; (you may want to try that if what I said didn’t work).

Let me know what happens or if you can post any files and I’ll see if I can help you out some. I’m still somewhat of a novice at actionscript but have run into enough problems that I have a lot of answers :slight_smile:

[QUOTE=bigdaddykraven;2324373]Hey, I’m not 100% sure I understand (its late and I’ve been coding all day and all night last night). Anyway, sounds like you have a main file and a movie clip on it (we’ll call it main_clip). Then it sounds like you loaded an external file into it and want a link from that external file to play in main_clip, replacing the external clip you are currently playing?

IF that’s the case, I believe you can do a simple:

_root.main_clip.loadMovie(“yourfile.swf”);

If my being tired has confused me, when you load a swf into another SWF’s movie clip, the main clip becomes the overall “root.” If you wanted to break this in the future and have the secondary clip be root for all the actions, you would put the code: this._lockroot=true; (you may want to try that if what I said didn’t work).

Let me know what happens or if you can post any files and I’ll see if I can help you out some. I’m still somewhat of a novice at actionscript but have run into enough problems that I have a lot of answers :)[/QUOTE]
Hey I appreciate the help because I am still learning alot my self. What’s happening is I have two movies on my main time line. One of them is loading movies as you described above _root.main_clip and the other is a second with some animation _root.second_clip.

Now once main_clip loads a movie via the loadMovie method: _root.main_clip.loadMovie(“external.swf”)

I was wondering if I can access the main time line from the external.swf via a button so that it can tell the _root.second_clip to animate. The button is on the external.swf’s timeline and I am just trying to figure out if it can communicate with the main time line via some kind of actionscript. All I want to do is be able to tell the second_clip to do is gotoAndStop(2) but I can’t figure out how to code the button on the external.swf to do that. I have a feeling it has something to do with the parent child relationship but I can’t figure it out.

Typically, when I run into parent/child problems, I go all the way back and label each step then strip things down from there just to see.

Like I said, I think once you load the external swf file, the main swf that you have loaded the external into becomes the “root.”

so for linking to your button, try something like:

_root.main_clip.bttnName.onRelease ()

Of course, if you have the button in a movie clip inside the external file, you’ll have to include that as well. If you can’t figure out what the problem is (parent/child things can be a headache) feel free to post your files on here and myself or someone else will be able to see it I’m sure. Usually easy problems can be seen when different eyes look at them.