Helpful Information
 
 
Category: Apache Flex
Play multiple FLVs through a single swf player in squence

I have a swf player which has multiple buttons to play other flvs.

The flvs start automatically, but stop after playing once. I want them to play one after the another one and on a timeless loop. There are four flvs and skin FLVcomponent link is myVideo.

http://www.*******************/?item=JW_FLV_Player

I would use this player, which has build in support for a playlist and all of the features you are talking about.

actually my flash player has a very customized design that I can't really change. So I will need to incorporate that functionality within the player.

Alright well there is a great tutorial about flash playlists on www.gotoandlearn.com, if you are interested in tackling that yourself. Otherwise I'm going to need to see some code or the FLA.

I woudln't know how hard it is to incorporate, but the tutorial would be a great place to start.

I will start with that. And if I run into problems I will ask you here.

thanks

i watched how to make a playlist through xml and then import it in flash. Actually I am looking for something very simple. Which is to basically play three-predefined videos one by one in the swf file. So I am willing to make changes to the *.fla file rather than dynamically updating videos through xml.

Any help in this regard will be helpful.

This is the code that I have used so far

myVideo is the instance name of the FLVPlayback component


myVideo.playPauseButton = play_paus_btn;
myVideo.muteButton = mute_btn;

promo_btn_01.onRelease = function():Void
{
myVideo.play("flv_video1.flv");
}

promo_btn_02.onRelease = function():Void
{
myVideo.play("flv_video2.flv");
}

promo_btn_03.onRelease = function():Void
{
myVideo.play("flv_video3.flv");
}


That is all. What I want to do is to play the flv_video1.flv, flv_video2.flv and flv_video3.flv in a sequence with a continuous loop, while the user also has the power to start any of the video by pressing the respective button as described in promo_btn_**. (the button functionality has already been incorporated)

Ok you need to do two things for the automatic looping.

1) Put your videos into an array


var videoList:Array = new Array();
videoList[0] = "video1.flv";
videoList[1] = "video2.flv";
videoList[2] = "video3.flv";
videoList[3] = "video4.flv";
var currentlyPlaying:Number = 0;

2) Setup a listener for the end of the currently playing video, and when complete have it start the next video in the array


import mx.video.*;
var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (videoList.length > currentlyPlaying) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
myVideo.play(videoList[currentlyPlaying]);
};
myVideo.addEventListener("complete", listenerObject);

I'm not 100% on the code, because I just wrote it without testing it. But look up the things in the documentation (http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00003537.html) if you need clarification what it is.

Hey friends, sorry if this is a dumb question, new guy here...

for the code above, how do you register the event listener to trigger when the video is done playing?

Also, perhaps we are not on the same page here but I am using AS 3.0 with my FLEX builder and cant find the mx.video package for some reason

I have the movie player up and running and I just want it to play a couple clips in a row

any help would be appreciated

Cain,

All of this code is for AS2, and AS3 is a whole different setup. I honestly don't know much about AS3, but www.gotoandlearn.com has some tutorials about video playlists.

i have put the first code in the global script to define the array.

but I am not sure how to setup the listener for the end of the movie.
can you please explain where I should be putting the second code.

thanks

I figured that must be why I couldn't find it... anyone know why this won't work? I want a video to launch and then during the first 5 (or 10, 20, etc.) seconds show one popup (if clicked) and during the rest of the show launch a seperate popup... its not working right though, it seems that it launches the first dialog box regardless

also ideal would be to just pass in a number or string so the dialog box could delegate internally what to display

I am working with the FLEX builder and AS3.0

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" verticalAlign="middle"
width="418" height="385">

<mx:Script>

<![CDATA[

<!-- Handles creating the pop up manager for the what was that window -->
import mx.managers.PopUpManager;

private function launchMoreInfo():void {


if (videoPlayer.playheadTime>5){
var win:Dialog = PopUpManager.createPopUp(this, Dialog, true) as Dialog;
}
else{
var win2:Dialog2 = PopUpManager.createPopUp(this, Dialog2, true) as Dialog2;
}
PopUpManager.centerPopUp(win);
}

]]>

</mx:Script>

<mx:VBox backgroundColor="white" width="416" height="383">
<mx:VideoDisplay width="415" height="349" id="videoPlayer"
source="./test.flv" />
<mx:HBox width="412" horizontalAlign="center">
<mx:Button label="Play" click="videoPlayer.play()" id="playButton"/>
<mx:Button label="What was that?" click="launchMoreInfo();videoPlayer.pause();"/>
</mx:HBox>
</mx:VBox>
</mx:Application>

@Cain you should start a new thread, since this is not the same issue.

The second part of the code should go just on the root timeline on the first frame (probably what you call the global script?)

@Cain you should start a new thread, since this is not the same issue.

The second part of the code should go just on the root timeline on the first frame (probably what you call the global script?)

I am not sure what I am doing wrong. But I pasted the code in the first frame of a layer called action. That is also where I have defined the other code that you mentioned. But it comes after the second code.

After publishing it. It plays the video which has been linked in the flvplayback component, and then it plays the last video in the array, i.e. flv_video3.flv. After playing that it stops.

What am I doing wrong?

Ok, its probably the code I wrote. At least it plays a second one, like I said I didn't test that code since I don't have your fla. Could you post that file?

Ok, its probably the code I wrote. At least it plays a second one, like I said I didn't test that code since I don't have your fla. Could you post that file?

This is the file that I have been working on
http://sbproductions.startlogic.com/hd/flash_skin_04.rar

btw, thanks for all the help. Really appreciate it.

Ok well I don't like to use the FLVPlayback, because it doesn't allow the same level of control that making it through AS does. But I think the issue is my listener code. I'm not able to load and test it on the machine I'm on right now (at school, no Flash), but its worth a shot. You will probably need to remove the parameters in the component, because it may cause some cross issues with the actionscript. We need all of the control in AS if possible, so turn off autostart, delete the src, and maybe a few others.


import mx.video.*;

var videoList:Array = new Array();
videoList[0] = "video1.flv";
videoList[1] = "video2.flv";
videoList[2] = "video3.flv";
videoList[3] = "video4.flv";
var currentlyPlaying = 0;

myVideo.play(videoList[currentlyPlaying]); // Should start the player without the parameters from the component

var listenerObject:Object = new Object();
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (videoList.length > currentlyPlaying) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
myVideo.play(videoList[currentlyPlaying]);
};
myVideo.addEventListener("complete", listenerObject); // Listen for the end of video

I will test later for sure, but perhaps it will help in the meantime.

Here is a great article about listening for the completion of a video.
http://www.quip.net/blog/2007/flash/actionscript-20/how-to-determine-completion-of-flv

I tried it.

Now it plays the first video rather than the last, which is a step in the right direction. But it stops after the first video has played.

Hmm it appears the listener is not catching the 'complete'. Odd.

I sat here testing for a few and have the solution I believe for real, and its tested (for a change!) Here is the code:


myVideo.playPauseButton = play_paus_btn;
myVideo.muteButton = mute_btn;

import mx.video.*;

var videoList:Array = new Array();
videoList[0] = "video1.flv";
videoList[1] = "video2.flv";
videoList[2] = "video3.flv";
videoList[3] = "video4.flv";
var currentlyPlaying = 0;

// Initialize first play
myVideo.contentPath = videoList[currentlyPlaying]; // Changed this as it is a specific function for changing the file
myVideo.play(); // Should start the player without the parameters from the component
trace(currentlyPlaying);

var listenerObject:Object = new Object(); // create listener object
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (currentlyPlaying > videoList.length) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
trace(currentlyPlaying); // Just traces new file in testing
myVideo.contentPath = videoList[currentlyPlaying]; // Change source file
myVideo.play(); // Play new file
};
myVideo.addEventListener("complete", listenerObject); // Initialize listener

Also, you have to be using at least Flash 8 for this all to work. I don't know what version you have but FLVPlayback is only partially supported before.

Also your buttons need this type of format:

btn_promo_01.onRelease = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[1]; // Change video source
myVideo.play(); // Start new video
}

Hope that makes it all work right!

Were you able to get the mask to work on a copy? I noticed it wasn't working on your FLA. Basically you add a new layer right above the video layer, and then right click on it and select Mask. Then add a rectangle to the stage on that layer (rounded if you want the edges rounded) and wherever the rectangle is, the video will show through only. Its pretty easy to do and good luck!

Thanks Man!! This works. The files are playing one by one. For the mask, I just covered the side edges with the background color that is on the website. As the player is opaque so I was not sure of masking working properly. Anyways I will be giving it a try.

Btw, there is just a small little quirk left. The movies start playing fine one by one, but the last movie plays twice before starting the loop again from video1.flv.

if (currentlyPlaying >= videoList.length) {

Add the = sign.

got it working. Thanks a lot

No problem :)

I am trying to acomplish what ksduded has, I want to play three .flv files one after the other on an endless loop. I am recently new to ActionScript although not entirely a noob.

I set up the FLVplayback, put the .flv files into an array, added the second peice of code which jeremywilken posted and set the contentpath (I'm useing AS 2.0).

Thankyou in advance.

Hi
Just curious to know if I am making use of swf files instead of FLV, would I use the same code to play multiple swf files in a sequence.
Please advise.
Thanks
uxk:)

Jeremy's scripts were exactly what I needed. Thanks jeremy.
Yet, there is something we need to fix
If you hit a button (say button for video3.flv) while player plays video1.flv, it stops and video3.flv starts playing which is good. The problem is after video3.flv comes to the end, next movie is video2.flv (which apperantly component returns playing its original sequence) rather than video4.flv (the one which comes after video3.flv) and after video2.flv, video3.flv starts again, which I watched.
What I want is player's playing the movies that come after that movie.

What can be done about that?

Thanks in advance

This should do it, but its untested since I no longer have this file setup. Also, welcome to the forums. I only ask that you don't PM about posts, there are other people here besides just me who can help, its just part of the forum etiquette.


btn_promo_01.onRelease = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[1]; // Change video source
currentlyPlaying = 1; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
}

Thank you for your answer. (sorry for pm'ing you, i just wanted to let you know about my post)

I added last codes you sent. However, problem goes on, flvcomponent act crazy once I hit the buttons. Say, while video1.flv is playing, i hit video 3 button and it starts playing, once it finishes, it should return to beginning, video1.flv that is. But video2.flv starts playing, or video3.flv starts playing second time. I dont know whats wrong

Thank you

Here is the sample fla Im working on..

http://www.freedrive.com/file/546237,flv_sequence.rar
(click blue arrow to download)

Ok I didn't explain, but on the button you need to set the currentlyPlaying = #. So the number should match the number in the array (video 1 is 0, video 2 is 1, vidoe 3 is 2).

Then there was a small issue with the counter being reset properly in the main timeline script.


myVideo.playPauseButton = play_paus_btn;
myVideo.muteButton = mute_btn;

import mx.video.*;

var videoList:Array = new Array();
videoList[0] = "video1.flv";
videoList[1] = "video2.flv";
videoList[2] = "video3.flv";
var currentlyPlaying = 0;

// Initialize first play
myVideo.contentPath = videoList[currentlyPlaying]; // Changed this as it is a specific function for changing the file
myVideo.play(); // Should start the player without the parameters from the component
trace(currentlyPlaying);

var listenerObject:Object = new Object(); // create listener object
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (currentlyPlaying >= videoList.length) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
trace(currentlyPlaying); // Just traces new file in testing
myVideo.contentPath = videoList[currentlyPlaying]; // Change source file
myVideo.play(); // Play new file
};
myVideo.addEventListener("complete", listenerObject); // Initialize listener


Button Example (change numbers to fit video in array)

btn_promo_01.onRelease = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[0]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
}

thanks a lot..
I have a great video mechanism now

Hi there,

Can someone help me :S I have used this script as well. But i doesnt loop. Only the first 3 then it stops at the 3. The buttons work fine!
Help!


import mx.video.*;

var videoList:Array = new Array();
videoList[0] = "marco.flv";
videoList[1] = "amy.flv";
videoList[2] = "guns.flv";
videoList[3] = "richie.flv";
videoList[4] = "ilze.flv";
var currentlyPlaying = 0;

// Initialize first play
myVideo.contentPath = videoList[currentlyPlaying]; // Changed this as it is a specific function for changing the file
myVideo.play(); // Should start the player without the parameters from the component
trace(currentlyPlaying);

var listenerObject:Object = new Object(); // create listener object
listenerObject.complete = function(eventObject:Object):Void {
currentlyPlaying++;
if (currentlyPlaying >= videoList.length) { // Resets counter if reaches end of array
currentlyPlaying = 0;
}
trace(currentlyPlaying); // Just traces new file in testing
myVideo.contentPath = videoList[currentlyPlaying]; // Change source file
myVideo.play(); // Play new file
};
myVideo.addEventListener("complete", listenerObject); // Initialize listener

myVideo.volume = off;

// Dit is de eerste button Marco
btn_promo_01.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[0]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;


txt_amy.gotoAndStop(1);
txt_lionel.gotoAndStop(1);
txt_ilse.gotoAndStop(1);
txt_marco.gotoAndPlay(2);
}
btn_promo_01.onRelease = function():Void
{
getURL("http://www.google.nl", "_blank");
}


// Dit is de tweede button Amy
btn_promo_02.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[1]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;


txt_marco.gotoAndStop(1);
txt_lionel.gotoAndStop(1);
txt_ilse.gotoAndStop(1);
txt_amy.gotoAndPlay(2);
}
btn_promo_02.onRelease = function():Void
{
getURL(clickTag1, "_blank");
}

// Dit is de tweede button Guns
btn_promo_03.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[2]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;


txt_marco.gotoAndStop(1);
txt_lionel.gotoAndStop(1);
txt_ilse.gotoAndStop(1);
txt_amy.gotoAndStop(1);
}
btn_promo_03.onRelease = function():Void
{
getURL(clickTag2, "_blank");
}



v// Dit is de derde button Richie
btn_promo_04.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[3]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;


txt_amy.gotoAndStop(1);
txt_marco.gotoAndStop(1);
txt_ilse.gotoAndStop(1);
txt_lionel.gotoAndPlay(2);

}
btn_promo_04.onRelease = function():Void
{
getURL(clickTag3, "_blank");
}

// Dit is de vierde button Ilse
btn_promo_05.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[4]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;

txt_lionel.gotoAndStop(1);
txt_amy.gotoAndStop(1);
txt_marco.gotoAndStop(1);
txt_ilse.gotoAndPlay(2);
}
btn_promo_05.onRelease = function():Void
{
getURL(clickTag4, "_blank");
}

Ok your buttons are causing issues because they have code which changes the videoList. Are you sure that these aren't causing the problem?


btn_promo_01.onRollOver = function():Void
{
myVideo.stop(); // Must stop currently playing video
myVideo.contentPath = videoList[0]; // Change video source
currentlyPlaying = 0; //Set the currentlyPlaying Marker
myVideo.play(); // Start new video
_root.myVideo.volume = 100;


txt_amy.gotoAndStop(1);
txt_lionel.gotoAndStop(1);
txt_ilse.gotoAndStop(1);
txt_marco.gotoAndPlay(2);
}

Maybe :S What do you think is the problem?

I don't know, but are you having the buttons change the video on rollover? That is what the code does now, which just seems strange from usability standpoint.

Did you change any other code?

Aaa the loop is oke i see. The flv was messeup :S
There is indeed a problem with the buttons. What should i do :S :confused:

What are you trying to do? If you want the buttons to change videos when the user clicks, then change .onRollOver to .onRelease.

If you want the buttons to do something onRollOver, then make another button event handler.

I dont have a clue :( Could you please help me with this handler?

I've asked you 3 times, what do you want to do? You did not write this code or do you understand any of it? What do you want help with????

Hi the main part wrote someone else. I only made some adjustments. But you say the best thing is to make a handler. Im not a dihard scripter :S. But thank for the help man!

Ok, I have been handling this thread for months, and wrote the main part posts. I know what it does. I've asked 4 times now, what are you trying to change the code to do!? If you do not answer I cannot help you. You don't have to be diehard at coding for me to help, you just need to be able to tell me what you need!!?!?

hey guys, please can anyone help me??
i need something similar like you all guys wanted but i need external .flv or .swf files to load and play on different parts of the page! can it be done via div tags somehow?? i cannot grasp that! so to be more precise, i have 4 flv files that i need to play in a sequence without any controls on the web page but they need to be on different parts of the web page that is made in html and not in flash! can it be done?? please a hint!

Umm yes it could be done, but the question is really if you are prepared to handle a tricky setup.

Basically you could utlilize the tutorials on www.gotoandlearn.com to learn about how to track when a FLV is finished. Then you'd need to use ExternalInterface to send a message to Javascript, which would then send a message to the next video to start playing. Its pretty convoluted, but its the only idea I have at the moment.

Is this really necessary? Besides if movies play on various parts of the page how do you ensure that your visitors won't get really annoyed?

Hmmm, thanks for the reply Jeremy.

Yes, that is a bit complicated. Ok in the meantime i have found a nice solution for my problem, but i try to do everything as the tutorial sazes and no result. I found a tutorial at
http://www.flashandmath.com/intermediate/externalclips/ext_clip3.html
and in their example they have 3 swf objects made entirely in Flash and 1 swf video that is imported in Flash and then they explain how to put one blank keyframe before and after the movie in which there is a stop; function and in the middle is a keyframe with the movie and with the following code:

import fl.video.FLVPlayback;
import fl.video.VideoEvent;

gledamsat.addEventListener(VideoEvent.COMPLETE,goNext);

function goNext(e:VideoEvent):void {
nextFrame();
}

stop();

where gledamsat is the instance name of the video.
After that they load all the swf files into another separate swf file that has only one frame with the following code:

/*
This file comes from www.flashandmath.com, a site moderated by Doug Ensley ([email protected]) and Barbara Kaskosz ([email protected]). It was developed as part of a project partially supported by the National Science Foundation and the Mathematical Association of America
*/

// Array of external clips to use. Variable index refers to next clip to be displayed.

var clips:Array=["film_index.swf","film_gledamsat.swf","film_glancam.swf","film_palacgore.swf"];
var index:int = 0;


// Stuff for loading files

var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);

var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC); // Add empty MC initially so the nextClip function works even on first call

// Gets the next MC, waiting for INITialization before adding it to the stage

function nextClip():void {
thisLoader.load( new URLRequest(clips[index]) );
}


// Remove old clip, tell AS that the loaded file is the new one, add it to the stage, and play.

function doneLoading(e:Event):void {
stage.removeChild(thisMC);
thisMC = MovieClip(thisLoader.content);
thisLoader.unload();
thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
stage.addChild(thisMC);
thisMC.gotoAndPlay(1);
}


// When currentFrame equals totalFrames in loaded clip (playing), increment index & play the next clip.

function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
index = (index + 1)%(clips.length);
nextClip();
}
}


// Call nextClip to automatically start the first clip

nextClip();



Ok, so in this code above i have put my 4 swf video files and i have made it all like the tutorial said but no result. The only difference beetween the example in the tutorial and my problem is that their array consists of 1.swf object made in flash, 2.swf extenal video, 3.swf object made in flash and 4.swf object made in flash. and my array is made of 4 swf video files.

Could You intuitively detect some odd logic in all of this?? Thanks for the time! You're a superhero!

Problem solved Jeremy, no need to bother!!! i didnt put the background in my swf video files and that was blocking everything!!

sorry for taking Your time!!

Ciao

OK, now i'm stuck on the last part of my swf video. Please guys if anyone can can help me say something, i don't know what else to do, i've been fighting with these flash files for 2 weeks and it's damn hard! Please help!

So, i am using the code written in the post above. I have 4 external swf files and the first one is intro and the rest of them should play in a loop after the first one finishes. Can this be done with actionscript?? What code do i have to write to play the first swf video only once and then the rest 3 all the time?? Thank You very much!!!

Okay i see the post got to page 4, so here is the code of the loader swf file:



/*
This file comes from www.flashandmath.com, a site moderated by Doug Ensley ([email protected]) and Barbara Kaskosz ([email protected]). It was developed as part of a project partially supported by the National Science Foundation and the Mathematical Association of America
*/

// Array of external clips to use. Variable index refers to next clip to be displayed.

var clips:Array=["film_index.swf","film_gledamsat.swf","film_glancam.swf","film_palacgore.swf"];
var index:int = 0;


// Stuff for loading files

var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);

var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC); // Add empty MC initially so the nextClip function works even on first call

// Gets the next MC, waiting for INITialization before adding it to the stage

function nextClip():void {
thisLoader.load( new URLRequest(clips[index]) );
}


// Remove old clip, tell AS that the loaded file is the new one, add it to the stage, and play.

function doneLoading(e:Event):void {
stage.removeChild(thisMC);
thisMC = MovieClip(thisLoader.content);
thisLoader.unload();
thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
stage.addChild(thisMC);
thisMC.gotoAndPlay(1);
}


// When currentFrame equals totalFrames in loaded clip (playing), increment index & play the next clip.

function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
index = (index + 1)%(clips.length);
nextClip();
}
}


// Call nextClip to automatically start the first clip

nextClip();

Try this for resetting the index to 1 instead of 0.


function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME, runOnce);
index++
if (index > clips.length)
{
index = 1;
};
nextClip();
}
}

Jeremy, thank You again for dealing with me!

I tried the code you suggested but i get an error 1021 duplicate function definition >> the source: function runOnce(e:Event):void {

Do you have any idea how to resolve this?

i tried to rename your part of the code into
function runOnce1(e:Event):void {
so they don't have the same name but the whole composition is looped again, it doesn't leave out the first movie

Actually you should replace the function with what I wrote, making a new function won't change the current one.

hehe, sorry, as you see i'm still an idiot for flash because i'm new to all of this!
Thank YOU Jeremy very much!!!!

You are welcome, everyone starts somewhere, trust me I have made some pretty big mistakes too - its the way one learns!

Hey, me again with stupid questions. I tried the code, but i cant get it to work. This is what i'm using on my preloader swf file:




/*
This file comes from www.flashandmath.com, a site moderated by Doug Ensley ([email protected]) and Barbara Kaskosz ([email protected]). It was developed as part of a project partially supported by the National Science Foundation and the Mathematical Association of America
*/

// Array of external clips to use. Variable index refers to next clip to be displayed.

var clips:Array=["film_index.swf","film_gledamsat.swf","film_glancam.swf","film_palacgore.swf"];
var index:int = 0;


// Stuff for loading files

var thisLoader:Loader = new Loader();
thisLoader.contentLoaderInfo.addEventListener(Event.INIT, doneLoading);

var thisMC:MovieClip = new MovieClip();
stage.addChild(thisMC); // Add empty MC initially so the nextClip function works even on first call

// Gets the next MC, waiting for INITialization before adding it to the stage

function nextClip():void {
thisLoader.load( new URLRequest(clips[index]) );
}


// Remove old clip, tell AS that the loaded file is the new one, add it to the stage, and play.

function doneLoading(e:Event):void {
stage.removeChild(thisMC);
thisMC = MovieClip(thisLoader.content);
thisLoader.unload();
thisMC.addEventListener(Event.ENTER_FRAME, runOnce);
stage.addChild(thisMC);
thisMC.gotoAndPlay(1);
}


// When currentFrame equals totalFrames in loaded clip (playing), increment index & play the next clip.

function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME,runOnce);
index++
if (index > clips.length)
{
index = 1;
}
;
nextClip();
}
}


// Call nextClip to automatically start the first clip

nextClip();



Can You detect any errors?

what do you do Jeremy? Is this Your forum??

Haha no this is not my forum. Technically I'm a student in Germany, although I do a lot of freelance work (mostly not Flash though).

I see a syntax error, a ; was in the wrong place and missing after index++, copy this over the current runOnce function.


function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME,runOnce);
index++;
if (index > clips.length)
{
index = 1;
}
nextClip();
}
}

thanks again man, i've put your code but it doesn't work..i'll try over at gotoandlearn forums. do you have any more ideas about why it doesnt work??
where are you in germany? i'm from croatia (i'm not hitting on you, i'm straight, don't worry, i'm just trying to chit-chat)

Well thats one of the things about Flash, its hard to see how things work without the FLA. However I need more information about what doesn't work, or what it is doing. I can't really guess how its working in its current state, so that would be a huge help.

Hey Jeremy, sorry i wanted to explain yesterday what was wrong but i forgot (because i was writing that at 2 am). Ok, so i put your code and the first swf movie plays and then the whole composition stops and nothing else happens. So only the first movie works and the second movie wont play. Do you have any idea now? Thanks!

to laganngurr: whats with the totaly random picture of a japanese school girl??

That was a spam message, it is gone now.


function runOnce(e:Event):void {
if (thisMC.currentFrame == thisMC.totalFrames) {
thisMC.removeEventListener(Event.ENTER_FRAME,runOnce);
trace("value of index was: " + index);
index++;
trace("value of index is now: " + index);
if (index > clips.length)
{
index = 1;
trace("value of index reset to: " + index);
}
nextClip();
}
}

Use this as your function, and tell me what comes out. If you run this in Flash it should spit out some messages about the value of the index. Let it run for as long as it seems like its running too. I'm having trouble calculating how it runs in my head, I'm a visual person.

Hey again, i appreciate your help soo much man! but nothing again, i know it's hard to guess like that.

Again the first movie plays and then it all stops, nothing plays after the first movie. In the output window i get a message:

value of index was: 0
value of index is now: 1

**** man, now i'm more annoying to myself than to you

i posted my problem at gotoandlearn forum but no one responds! can you suggest anything else? Thanks man!!!

Are you able to load the FLA here? I'd take a crack at it, its something that looks like it would be a lot faster if I just opened the FLA.

grrr, i can't upload to this forum, only if you give me your email address so i can send you the whole folder with all the files or do you only want the loader.fla???

man, i am a little embarassed because you are taking so much time to solve this. I don't know how could i repay you! i could send you a small donation via paypal, couple of euros, not much, just to say thank you! i would like to send you 5 E, i know it's piss but i don't have much money now.

Do you want this "job"? Can you give me your mail

i forgot to ask you, for who are you cheering, hsv or werder:)??

Drat you have CS4 don't you? Can you save them as CS3 or lower and resend them?










privacy (GDPR)