This is Interesting: Free Magazines for Graphics designers and webmasters  


Home > Archive > Flash Site Design > November 2006 > Playing two external swfs together





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Playing two external swfs together
Motty99

2006-11-05, 10:33 pm

trying to get two swfs, which are different sizes and take different times to
load in a low speed enviroment, to play together...possibly a listener?...any
demo code would be most appreciated!

Thanks!

Motty99

2006-11-05, 10:33 pm

Thanks droopy!...will work on it and let you know...
droopy.ro

2006-11-05, 10:33 pm

ok i made a quick code based on some example.
just paste it in the first frame of a new movie clip, and test it(Ctrl+Enter)
... and you will see the way it works. i hope this is helpful. let me know if
you have any problems with it.oh and yeah.. just change the movies to the ones
you need to load.

the point is that when they are both loaded just start to play them..

var loadListener:Object = new Object();
completed=0
loadListener.onLoadComplete = function(target_mc:MovieClip,
httpStatus:Number):Void {
completed+=1;
trace(completed+" object/s loaded");
if (completed==2) {
//both movies completed
}
}
loadListener2.onLoadComplete = function(target_mc:MovieClip,
httpStatus:Number):Void {
completed+=1;
trace(completed+" object/s loaded");
if (completed==2) {
//both movies completed
}
}

var mcLoader:MovieClipLoader = new MovieClipLoader();
mcLoader.addListener(loadListener);


var mc:MovieClip = this.createEmptyMovieClip("mc", this.getNextHighestDepth());
var mc2:MovieClip = this.createEmptyMovieClip("mc2",
this.getNextHighestDepth());
mcLoader.loadClip("http://www.w3.org/Icons/w3c_main.png",mc);
mcLoader.loadClip("http://www.droopy.ro/exemples/loop.swf",mc2);

droopy.ro

2006-11-05, 10:33 pm

well, if you are using preloaders.. then when one of the preloaders reachees
100% then the laoded moves should stop, untill the other one loads too. so ..
[i]//when the first move loads
firstMovieLoaded.stop();[/i]
when both of the preoloaders got to 100% then the first movie laoded should
start playing and so does the second one
[i]//if both preloders got to 100%
firstMovieLoaded.play();
secondMovieLoaded.play();[/i]
something like this should be, but i don't know exactly how you could
implement that or if will really work. theoreticly should work. maybe you could
send me the code you are using to load the movies..


Motty99

2006-11-05, 10:33 pm

Hmmm...the problem is that I'm using preloaders for the swfs...not following
how you accomplish the playing of both swfs at the same time, though different
load times...I'm not new to flash, but not a great coder...

Motty99

2006-11-05, 10:33 pm

sounds like what I need droopy...using a purchased preloader (uniloader)...they
have afterload functions...the docs say:
The actions play, stop, gotoAndStop and gotoAndPlay are for controlling the
loaded SWF file. In the input fields for gotoAndPlay and gotoAndStop you can
enter the number of the frame or the frame's label.

To set more complicated actions you should use the onLoaded handler option.
You should enter the name of the function you wish to call after loading has
completed in the onLoaded handler input field

Perhaps the onLoaded handler is my best option...but unsure how to implement...


droopy.ro

2006-11-05, 10:33 pm

well, you have to know if onLoaded is called by the first movie that laods or
the second one. for this you could ad a variable that increment once a movie is
loaded. see the first example that i attached(see how [i]completed[/i] is
[i]=0[/i] and then once a movie loads [i]completed+=1[/i] - this increments it
by 1 - so when the [i]completed[/i] variable will reach 2 you will know that
both movies are loaded. anyway. when the onLoaded is called you should check if
[i]completed[/i] is 2 otherwhise increment it and [i]stop()[/i] the loaded
movie clip. if [i]completed[/i] is 2 then start the first movie and should work
fine. to start the first movie loaded use the name of the container movie clip
in which you load it like: [i]container_mc.start();[/i]
i hope this works.

Motty99

2006-11-05, 10:33 pm

That sound exactly like what I want to do...on the faster loading clip,
complete=0, have a listener set up, so that onloadcompete, mc.stop()...on the
next line, have an if/then(else?) statement that looks for complete to equal
1...have the first movie a listener, and onloadcomplete complete+=1, this will
start the second movie...

Does the logic sound ok?

droopy.ro

2006-11-05, 10:33 pm

well, i think so.. anwyay, try it. if it doesn't work.. contact me by my email, and will try to solve this..

Sponsored Links


Copyright 2003 - 2008 forum4designers.com  Software forum  Computer Hardware reviews