views:

560

answers:

2

I have a Flash AS2 application that is made up of many SWF files. I need to create an OnClick event in a container SWF that will work for every SWF called. I am trying to avoid adding code to every SWF (over 100).

Currently I can get access to the click in the container for the first SWF but when the second SWF is called it seems to overwrite the container.

this._lockroot = true;

this.onMouseUp = function(){
    //if not on login
    getURL("javascript:clickTest();");
};

//load swf
loadMovie("test.swf","_level2");

How do I make where a click in the container will be triggered even if the SWF inside the container calls another SWF?

This seemed so simple but has been a nightmare. Is it even possible?

+1  A: 

Edit (re: comments, onClipEvent shenanigans didn't work)

How about trying something like this:

this.createEmptyMovieClip("holder", this.getNextHighestDepth());
loadMovie("test.swf","holder");

instead of:

//load swf
loadMovie("test.swf","_level2");

Or, if _level2 is necessary to the structure of the app, something like this:

_level2.createEmptyMovieClip("holder", _level2.getNextHighestDepth());
_level2.holder.loadMovie("test.swf");

I just tried this out with a 2-level nested load, and it maintained the click handler in the top level (while using a loadMovie w/o the holder didn't). I'm not sure if the assumptions I made match the structure of your nested SWFs, but that's my best guess at this point.

datageist
The problem is not that the code does not work with the click event it is the problem of the click event persisting after a new swf is called by the embedded swf.
Todd Moses
It is not a movie clip - thus the onClipEvent does not work.
Todd Moses
what's the code that the loaded SWFs are using to load other SWFs?
datageist
they are using loadMovie too.
Todd Moses
A: 

You could have movieClip named e.g. clickHaver on top layer (at all costs) - if second movie (and each next) loads the next movie into itself:

- container
  - loads movie.swf
    - loads movie2.swf

then your only concern is to keep clickHaver on top after loading the first movie, since every next loads another .swf file in itself.

Adam Kiss