Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Play multiple .SWF in sequence

New Here ,
Aug 13, 2010 Aug 13, 2010


I have two swf files that I would like to play in sequence in a main  flash file.  The two swf files are partA.swf and partB.swf. I set up two  frames using this actionscript 3 snippet:

Frame 1:

Code:
var partARequest:URLRequest = new URLRequest("partA.swf");
var partALoader:Loader = new Loader();
partALoader.load(partARequest);
addChild(partALoader);
Frame 2:
Code:
var partBRequest:URLRequest = new URLRequest("partB.swf");
var partBLoader:Loader = new Loader();
partBLoader.load(partBRequest);
addChild(partBLoader);
I made sure to set new loaders that  correspond to it's proper swf file. So partA.swf goes with partALoader  and partB.swf goes with partBLoader.

I noticed that individually they work great. If I just set up frame 1 or  frame 2 by themselves, the swf file plays. When placed together,  however, either frame 1 plays without going to frame 2 OR frame 2 plays  by default without playing frame 1 first.

How can I get this to work properly in sequence?

Just to break things down, this is how I would like the set up.

1. Play frame 1 which plays partA.swf,
2. Stop when finished and go to frame 2 which plays partB.swf
3. Stop movie, no need to loop.
4. Would like to have option for adding more swf files

I don't use flash much, so guidance with code is much appreciated. I  would think this is a simple task, but searching for a proper solution  hasn't been successful.

Also just to clarify from previous searches and posts I looked at: I am  not using buttons, and this is using actionscript 3.0 not 2.0, and this  is using only .swf files.

Thanks a bunch
TOPICS
ActionScript
3.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 13, 2010 Aug 13, 2010

Here's a nice trick that Andrei1 taught me  a week ago or so that should sort out your problem:

On the last frame of partA.swf, you could dispatch an event, like so:

dispatchEvent(new Event("advanceParentTimeline"));

Then, in your parent movie on the frame that partA gets loaded, you can listen for the text, like so:

stage.addEventListener("advanceParentTimeline", onTextRequest, true);

Add the following function to the same frame with the listener mentioned above, and if your parent movie hears that text, send your movie to frame 2, like so:

function onTextRequest(e:Event):void {
     gotoAndStop(2);
}

Hope that helps,

~Chipleh

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2010 Aug 13, 2010

Errors are not compiling, but the movies aren't appearing right. It's just rapidly blinking. What could be causing this?

Thanks for your reply

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 13, 2010 Aug 13, 2010

Most likely a script error, which tends to make movies "flash rapidly"

Post the code you're using in your parent and child movies so we can take a look.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 13, 2010 Aug 13, 2010
LATEST

Sure thing:

Parent:

Frame 1 calling PartA.swf:

var partARequest:URLRequest = new URLRequest("partA.swf");
var partALoader:Loader = new Loader();
partALoader.load(partARequest);
addChild(partALoader);
function onTextRequest(e:Event):void {
     gotoAndStop(2);
}
stage.addEventListener("advanceParentTimeline", onTextRequest, true);

Frame 2 calling PartB.swf:

var partBRequest:URLRequest = new URLRequest("partB.swf");
var partBLoader:Loader = new Loader();
partBLoader.load(partBRequest);
addChild(partBLoader);


-----------------------------------------------------------------------------------------------------------------------

PartA.swf

dispatchEvent(new Event("advanceParentTimeline"));

PartB.swf

-- no actionscript --

Thank you

Chris

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines