FORUMS: list search recent posts

Trying to create loop to show 5 movies sequentially ...

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Cornelius Matteo
Trying to create loop to show 5 movies sequentially ...
on Jun 2, 2006 at 5:06:15 pm

Hello,

I am very new to Flash (using 8.0) and trying to create an action script that will simply
loop through 5 times so I can show 5 flv files in sequential order.
The files are in the same directory and are named: testimonial1.flv ... testimonial2.flv ...

Here is script I have so far, but it does not show any of the flv files? Any suggestions??


var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);
theVideo.attachVideo(ns);


var timer:Number = 0;

do {
timer++;
trace(timer);
theVideo.attachVideo(ns);
ns.play("testimonial"+timer+".flv");
} while (timer < 6 );



Return to posts index

lajoiet
Re: Trying to create loop to show 5 movies sequentially ...
on Jun 2, 2006 at 9:00:05 pm

I'm not sure you that the way you are combining the name elements (I always forget what they call that, concantenating or something...) will actually work, but I do know that the do...while loop is the wrong way to go about doing what you want. I would toss your 5 FLV names into an array and set up a counter variable:

var myArray:Array = Array("testimonial1.flv", "testimonial2.flv","testimonial3.flv", "testimonial4.flv", "testimonial2.flv");
var whoIsOn:Number = 0;

Then give the netStream the first video to play:

ns.play(myArray[whoIsOn]);

and set up an ns.onStatus function that will watch for the signal that a video is done playing (this is the big thing that's missing from the do...while) And if there are any videos left, play the next one:

ns.onStatus = function (info) {
trace("OnStatus = "+info.code);
if (info.code == "NetStream.play.Stop") {
whoIsOn++;
if (whoIsOn < myArray.length){
ns.play(myArray[whoIsOn])
}
}
}


>Todd
_____________________________________

I'm filling a need. Without me there would be no bad examples.
_____________________________________


Return to posts index

Cornelius Matteo
Re: Trying to create loop to show 5 movies sequentially ...
on Jun 5, 2006 at 5:41:28 pm

Thank you.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]