0

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?

3
  • Is that the code in the clips being loaded, or the code in the container? Just for clarification, you've got one container, which loads any of >100 other clips, which then in turn load other clips? Or do the >100 clips load each other in sequence (after the first has been loaded by your container)? Commented Feb 25, 2010 at 16:07
  • The original did not have a container. I just added it to hold the code above. The SWF contained in the container have links that load other SWF files based on what the user is doing. Commented Feb 25, 2010 at 16:13
  • I think once the contained SWF calls another SWF the container goes away. I do not know how to have the container remain through the calls to other SWF files. Commented Feb 25, 2010 at 16:14

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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.
what's the code that the loaded SWFs are using to load other SWFs?
they are using loadMovie too.
0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.