Skip to main content
September 6, 2006
Question

Communicating between swf files

  • September 6, 2006
  • 4 replies
  • 238 views
Okay here is my senario:

I have two files, one is main.swf and the other one is sub.swf. sub.swf is an external swf that i loaded into main.swf on _level1. In the sub file I have a movie clip and when it is clicked on it needs to tell the main file (the host) what to do...how do i go about referring to the main.swf?

any info would help!
This topic has been closed for replies.

4 replies

September 6, 2006
you rock! thank you so much...i got it to work...on to my next item to fix :-)
Inspiring
September 6, 2006
It shouldn't. If sub.swf is truly loaded into _level1 then it has no _level0, really this is correct!

Are you sure you are loading into a _level and not onto a depth? Many folks mix the two up.

If you are having a lot of trouble with this it is generally a good idea to set your current project aside for the moment and start with a fresh slate. I created two swf files.

test1.swf has a blue square and code to load an external clip into _level1 the code is:

loadMovieNum("test2.swf",1);

test2.swf has a movieclip instance of a red circle and the following actionscript:

myClip.onRelease=function(){
_level0._alpha=50;
}

When test1.swf is run I see both my blue square and my red circle. When I click on the red circle only the blue square (the art work on _level0 from the original swf) is made 50 percent opaque. The red circle remains as it was.

You might want to try a similar test, starting with something like I have and moving it toward what you are trying to achieve. I'm not sure I understand your

_level0.myVariable.goDoThis()

syntax. myVariable seems like a property and properties don't usually have methods so I don't quite get it. If myVariable is a variable defined in the sub.swf then maybe you need this:

_level0[myVariable].goDoThis();

???
September 6, 2006
alright...but when i asked the movie clip in the sub swf file to do this:

movieClip.onRelease = function (){
_level0.myVariable.goDoThis();
}

it refers back to level 0 of the sub swf...not the main swf that it loads into...
Inspiring
September 6, 2006
The main.swf (and the first swf no matter what it is called) into _level0. (That is a zero.) So if sub.swf needs to get something from main it would be like this.

if(_level0.myVariable == "bonus"){}

Or if you need to have to have a movie on the main timeline of main.swf play you would do.

_level0.myInstance.play();

And so forth.