I am designing a website with Flash CS3, using actionscript 2.0. I am reasonably comfortable with actionscript, but not an expert.

I have a main timeline containing my basic page layout with buttons linking to my other pages.
My other pages load as swf files when the appropriate button is clicked.
I want to be able to load one swf over the previous one for page transitions.

My two problems are not being able to access the timeline of the loaded swf, and as mentioned, not being able to load a swf over a still visible swf.

I've tried every method I could find for a few days now, including Loader components and countless actionscript variations.

Any help or direction to some tutorials would be appreciated.
Thanks.

Dani AI

Generated

Follow-up note tying and posts together with a practical AS2 pattern for loading an external SWF on top of the current one and reliably triggering its own timeline/animation.

A reliable approach is to load each page into its own container MovieClip, use MovieClipLoader with an onLoadInit handler, then call an explicit entry function or play a labeled frame inside the loaded SWF. This avoids timing problems (calling the loaded timeline too early) and keeps stacking under control.

var mcl:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();

mclListener.onLoadInit = function(target_mc:MovieClip) {
    // position off-stage (slide-in start)
    target_mc._x = Stage.width;
    // call an entry point the loaded SWF defines on its main timeline
    if (typeof target_mc.startTransition == "function") {
        target_mc.startTransition();
    } else {
        target_mc.gotoAndPlay("in");
    }
};

mcl.addListener(mclListener);
this.createEmptyMovieClip("pageHolder", this.getNextHighestDepth());
mcl.loadClip("page1.swf", this.pageHolder);

Tips and troubleshooting

  • Use an entry function or labeled frame inside the loaded SWF (for example, the loaded movie's first frame can set this.startTransition = function(){ gotoAndPlay("in"); }). Calling that from onLoadInit is safe.
  • Wait for onLoadInit. Trying to call frames or functions immediately after loadClip often fails.
  • Ensure both loader and loaded SWFs target the same AVM (AS2). An AS3 root cannot control an AS2-loaded movie (it becomes an AVM1Movie).
  • Avoid relying on _root inside the loaded SWF; prefer local this or an exposed function. If necessary, use MovieClip._lockroot on the loaded movie (set inside that SWF) so _root refers to its own timeline.
  • For stacking, use getNextHighestDepth() or explicit depths so incoming pages sit above existing content. Unload previous clips with MovieClipLoader.unloadClip() or removeMovieClip() after the transition finishes.

Scenes are a simple fix for small sites (as decided), but the container + MovieClipLoader pattern scales better for modular pages and controlled transitions.

Recommended Answers

All 6 Replies

Do you want the loaded movie to take the place of the current movie when the button is clicked? I can't think of what the command is off the top of my head (I want to say LoadMovie but cant remember and I'm at work so cant check it out) in which you specify what layer you want to load the movie into and if you set the parameter to 0 it will replace the current movie.

I want the swf that is loading to load over the current one, while it is still visible.
It should seem that the swf is sliding over the one already visible.

I think a parameter of 1 with the LoadMovie actionscript will load it above the current movie without wiping out the timeline of the original movie.

Thanks, I've managed to work around most issues, I can get swfs to load over others, only as movie clips.
My problem now is how to access the timeline of the loaded movieclip, play an animation, and then load the new movie over the current one.
Most of my efforts result in my code ignoring the call to the loaded (not the root) timeline, and just loading the new clip over the old.

Please clarify. So your page design is a flash object with buttons. When you click a button, you want a movie to come in to only do a transition and nothing more. Or do you want the new movie to stay for the duration until they click another link to take them to another movie?

If the idea is to have a transition when they click a button, why not just incorporate all of that into different scenes within the original flash movie and set your buttons to jump to the different scenes. The first frame of the scene will look that same as the page with the buttons and set a motion tween to moridy it however you want.

Thanks for all.
This is a good lesson for me to lay out my site better next time.
I will put it on different scenes.

I was making things too difficult.

Tunnel vision....

Thanks again.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.