Highlighted

Play different SWF one after another

Community Beginner ,
Nov 30, 2019

Copy link to clipboard

Copied

Hello

 

I'm looking for a way to play different Animations (SWF) after each other with the following sequence made in Animate/Flash:

 

1. Load SWF 1 + 2 + 3...

2. When all are loeaded, wait. Do not start!

3. After klick "Play" the first SWF starts

4. At the end of SWF 1 the SWF 2 automatically starts

5. go ahead with SWF 3 + 4 .....

 

And it is important, that the crossing from 1 to 2 is exactly in time. So Frame by Frame. A solution with a time counter will not work due to synchronisation.

And it has to work on a local computer. Not online.

 

Thanks very much for your input!

 

Greez

Yuna

TOPICS
ActionScript, How to

Views

99

Likes

Translate

Translate

Report

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

Play different SWF one after another

Community Beginner ,
Nov 30, 2019

Copy link to clipboard

Copied

Hello

 

I'm looking for a way to play different Animations (SWF) after each other with the following sequence made in Animate/Flash:

 

1. Load SWF 1 + 2 + 3...

2. When all are loeaded, wait. Do not start!

3. After klick "Play" the first SWF starts

4. At the end of SWF 1 the SWF 2 automatically starts

5. go ahead with SWF 3 + 4 .....

 

And it is important, that the crossing from 1 to 2 is exactly in time. So Frame by Frame. A solution with a time counter will not work due to synchronisation.

And it has to work on a local computer. Not online.

 

Thanks very much for your input!

 

Greez

Yuna

TOPICS
ActionScript, How to

Views

100

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Nov 30, 2019 0
Adobe Community Professional ,
Dec 01, 2019

Copy link to clipboard

Copied

Hi.

 

Here is an example of how you could do this.

 

Main FLA/SWF AS3 code for the 1st frame:

import flash.display.Loader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
import flash.events.MouseEvent;

var swfs:Vector.<String> = new <String>["test0.swf", "test1.swf", "test2.swf", "test3.swf"];
var swfContainers:Vector.<MovieClip> = new <MovieClip>[swf0, swf1, swf2, swf3];
var loaders:Vector.<Loader> = new Vector.<Loader>(swfs.length, true);
var swfCount:uint = 0;
var queueCount:uint = 0;

function start():void
{
	disablePlayButton();
	loadQueue();
	playButton.addEventListener(MouseEvent.CLICK, playNext);
}

function loadQueue():void
{
	for (var i:int = 0, total:int = swfs.length; i < total; i++)
	{
		loaders[i] = loadSWF(swfs[i]);
		loaders[i].contentLoaderInfo.addEventListener(Event.COMPLETE, swfLoaded);
	}
}

function loadSWF(url:String):Loader
{
	var loader:Loader = new Loader();
	var urlRequest:URLRequest = new URLRequest(url);
	loader.load(urlRequest);
	return loader;
}

function swfLoaded(e:Event):void
{
	swfCount++;
	
	if (swfCount == swfs.length - 1)
		enablePlayButton();
}

function playNext(e:MouseEvent):void
{	
	var timeline:MovieClip;
	
	swfContainers[queueCount].addChild(loaders[queueCount]);
	timeline = MovieClip(loaders[queueCount].content);
	timeline.gotoAndPlay(1);
	
	if (queueCount === 0)
		disablePlayButton();
	
	queueCount++;
}

function enablePlayButton():void
{
	playButton.mouseEnabled = true;
	playButton.alpha = 1;
}

function disablePlayButton():void
{
	playButton.mouseEnabled = false;
	playButton.alpha = 0.5;
}

start();

 

Child FLA/SWF AS3 code for the last frame (except for the last FLA/SWF):

stop();

if (parent.parent)
{
    MovieClip(parent.parent.parent).playNext(null);
}

 

Source / FLA / files:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/as3/load_swfs_and_play_in_sequence

 

 

I hope this helps.

 

 

Regards,

JC

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Community Beginner ,
Dec 01, 2019

Copy link to clipboard

Copied

Dear JoãoCésar


First, thank you very very much for your detailed anser! I really appreciate that!


Since I'm a newbie in Actionscript I try just to copy your code in a new project. Created 4 animations and put the name in your array in line 8.


Just without doing something else, I excecute the code. And first i receive the error for not defined variable. So I disabled "Strict Mode". If I publish now, it creates no errors. But also nothing happens.

If I do not publish but say preview (CTRL+Enter) I get an reference error #1065: Variable swf0 is not defined.

Since I have no idea for what you are using this row, I don't know how to fix it.

Further you create a Play Button right? Do I have to define a Button at the stage for this function?


Thanks for helping a stupid newbie run its simple code...

Greetings Yuna

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Adobe Community Professional ,
Dec 01, 2019

Copy link to clipboard

Copied

You're welcome!

 

And have you tried downloading the files here:

https://github.com/joao-cesar/adobe/tree/master/animate%20cc/as3/load_swfs_and_play_in_sequence

?

 

If you have, even starting from the files provided are you encountering the issues mentioned?

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Community Beginner ,
Dec 01, 2019

Copy link to clipboard

Copied

Oh man no I don't! Sorry!

Now it is clear with the "containers".

 

I tried to apply it on my project. So just put all your files in a folder and replace your test0.swf with mine. Two problems then:

1. I have music implemented (stream). the music starts immediately. not after "play"

2. if press play then, the animation doesn't start at the beginning

 

 

See my test SWF here:

https://drive.google.com/open?id=1QgWTSfXSDD0NyLpdYcdEA7KTsH66mM60

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Adobe Community Professional ,
Dec 01, 2019

Copy link to clipboard

Copied

Nice!

 

1. If you are using timeline sound, a possible solution is to move the beginning of your music to the 2nd frame and let a stop instruction in the first frame. Then in the playNext function you can tell the timeline to play from the second frame.

 

2. It highly depends on how your timeline is structured. If you have nested timeline animations then you're gonna need to control them individually.

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Community Beginner ,
Dec 01, 2019

Copy link to clipboard

Copied

Yes  I already tried with stop() and gotoAndPlay(2)

But with my SWF there is a "TypeError: Error #1034:"

Cannot be converted into movieclip. is there a problem with my SWF?

 

EDIT:

I tried copy your original FLA0. Delteded all your animations. Copied all animations from my FLA1 and insert into yours.

-> it works! why?

You have different frame rate -> already tested

you have different resolution -> already tested

 

 

EDIT2:

As I said.... newbie... -.-

Found the error. My file was a Actionscript 2 File!

Convert it to AS3 and it works.

 

Thanks a lot for your help!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 1
Adobe Community Professional ,
Dec 01, 2019

Copy link to clipboard

Copied

Why don't you just copy every SWF's timeline into a single SWF? What's the reason they have to be separate SWFs?

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 01, 2019 0
Adobe Community Professional ,
Dec 02, 2019

Copy link to clipboard

Copied

Excellent! You're welcome! And I'm glad you found out the issue!

__________________________________________
HTML5, JSFL, and AS3 samples: http://bit.ly/2mJgDoG

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 02, 2019 0
Community Beginner ,
Dec 03, 2019

Copy link to clipboard

Copied

Dear Clay

 

Thanks for your interesting. The reason is, that the animation is about 17 minutes. And with the frame limitation it doesn't work.

Thats why I'm wondering how other people are doing this. Because a lot of animations are longer than 17 minutes. but I guess they cut and merge them with a video editor.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2019 0
ClayUUID LATEST
Adobe Community Professional ,
Dec 03, 2019

Copy link to clipboard

Copied

Animate's frame limit is only per-timeline. For arbitrarily long animations, just split them up into movieclips. Order each movieclip immediately one after the other in single frames on a single layer on the root timeline. Like so:

Frame 1: Movieclip 1

Frame 2: Movieclip 2

Frame 3: Movieclip 3

etc...

 

In the last frame of each subclip, put:

// ActionScript 2

stop();

parent.nextFrame();

 

or...

 

// ActionScript 3

stop();

MovieClip(parent).nextFrame();

 

There, now you don't have to mess around with multiple SWFs and load delays.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2019 0
Community Beginner ,
Dec 03, 2019

Copy link to clipboard

Copied

Dear JoãoCésar

 

Now it's working with play all animations. But now I have the problem, that the animations lags between the change from each SWF.

 

See example here:

https://drive.google.com/open?id=1V-5FjfNfxdK4qY-BRKQ4fYMb7skwAWyV

 

can it be, because with "load" only the SWF till Frame 1 will be loeaded? And now I moved the music into frame 2, so the "biggest part" is not loeaded. And if we jump to frame 2, the program has to reload the rest of the SWF before it can go ahead? sound this logical? and how we can fix that?

 

Thanks for your ideas.

 

Regards

Yuna

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 03, 2019 0