FORUMS: list search recent posts

Looping Multiple FLV files in Flash CS3

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jim Zons
Looping Multiple FLV files in Flash CS3
on Jul 8, 2008 at 2:12:27 am

Okay ... here's maybe an easy one for someone who knows what they are doing! I am not well-versed in Action Script 3 ... I'm just a hacker. I have created a Flash project where I have three instances of a very small FLV movie that I want to loop endlessly when launched in a user's browser. Using this bit of Action Script:

import fl.video.*;

// Video component instance name
var flvControl = flames1;
var flvSource = "flames.flv";

// Loop the video when it completes
function completeHandler(event:VideoEvent):void
{
flvControl.seek(0);
flvControl.play()
}
flvControl.addEventListener(VideoEvent.COMPLETE, completeHandler);

// Set video
flvControl.source = flvSource;



I can make one instance of the video repeat, but not the other two. Right now, I have the three instances of the video on a single layer, but even if I move it to other layers so that they are all on separate layers, I then get Action Script errors and none of the videos loop. I even tried having it call up three SEPARATE videos (which seems unnecessarily wasteful when it is the exact same video) I get more Action Script errors:

1151: A conflict exists with definition flvControl in namespace internal

1021: Duplicate function definition

Any ideas how I can get all three videos to loop? Here is a link to what I am actually trying to accomplish:

http://7stream.net/fireside/home.html

Note that the middle fireplace flames loop, but the one on the left and the one on the right do not .... I would like these to loop like the center fireplace. Any and all suggestions are welcome!


Return to posts index

Pieter Helsen
Re: Looping Multiple FLV files in Flash CS3
on Jul 8, 2008 at 7:30:49 am

What does this do for you?
import fl.video.*;

// Video component instance name
// You need to change the instance name of your video components
// It uses the same source for each instance
var flvControl1 = flames1;
var flvControl2 = flames2;
var flvControl3 = flames3;
var flvSource = "flames.flv";

// Loop the video when it completes
function completeHandler(event:VideoEvent):void
{
flvControl.seek(0);
flvControl.play()
}

flvControl1.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl2.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl3.addEventListener(VideoEvent.COMPLETE, completeHandler);

// Set video
flvControl1.source = flvSource;
flvControl2.source = flvSource;
flvControl3.source = flvSource;


Kind regards,
Pieter


Return to posts index

Jim Zons
Re: Looping Multiple FLV files in Flash CS3
on Jul 8, 2008 at 11:44:17 am

Pieter ... wow ... really close. I was still getting an error for an undefined element, so I looked closely at the scripting, and hacked this solution:


import fl.video.*;

// Video component instance name
// You need to change the instance name of your video components
// It uses the same source for each instance
var flvControl1 = flames1;
var flvControl2 = flames2;
var flvControl3 = flames3;
var flvSource = "flames.flv";

// Loop the video when it completes
function completeHandler(event:VideoEvent):void
{
flvControl1.seek(0);

flvControl1.play()

flvControl2.seek(0);

flvControl2.play()

flvControl3.seek(0);

flvControl3.play()
}

flvControl1.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl2.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl3.addEventListener(VideoEvent.COMPLETE, completeHandler);

// Set video
flvControl1.source = flvSource;
flvControl2.source = flvSource;
flvControl3.source = flvSource;


I needed to create three separate flvControl.seek/play commands and that did the trick! I've posted the fixed animation to the same location:

http://7stream.net/fireside/home.html

Thanks again!



Return to posts index


Pieter Helsen
Re: Looping Multiple FLV files in Flash CS3
on Jul 8, 2008 at 12:35:48 pm

This should work as well and would be easier still :)

// Loop the video when it completes
function completeHandler(event:VideoEvent):void
{
this.seek(0);
this.play()
}

In any case, glad you managed to get it fixed.

Kind regards,
Pieter


Return to posts index

Jamie Kehoe
Re: Looping Multiple FLV files in Flash CS3
on Apr 23, 2009 at 6:19:47 pm

Ok guys, a challenge for you. I have exactly the same thing, except I need to have 3 separate videos playing in a header section and constantly looping. This is the code based on your example.

import fl.video.*;

// Video component instance name
// You need to change the instance name of your video components
// It uses the same source for each instance
var flvControl1 = vid1;
var flvControl2 = vid2;
var flvControl3 = vid3;
var flvSource = ["Statue.flv","Bush.flv","Clouds.flv"];
var loopAtEnd = true;


// Loop the video when it completes
function completeHandler(event:VideoEvent):void

{

flvControl1.seek(0);

flvControl1.play()

flvControl2.seek(0);

flvControl2.play()

flvControl3.seek(0);

flvControl3.play()

}

flvControl1.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl2.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl3.addEventListener(VideoEvent.COMPLETE, completeHandler);

// Set video
flvControl1.source = "Statue.flv";
flvControl2.source = "Bush.flv";
flvControl3.source = "Clouds.flv";

Problem is that each video finishes when the shortest video finishes and they all loop at the same time. How do I avoid this so each loops at the end of its own time?

G5 Dual 2.3GHZ
2.5GB DDR SDRAM 400MHZ
Mac OS 10.5.1
2 x 20" Apple Cinema Display
128MB ATI Graphics


Return to posts index

demetri tashie
Re: Looping Multiple FLV files in Flash CS3
on May 28, 2009 at 2:26:59 pm

the problem is your functiopn is telling all three video players specifically what to do, all at the same time, so yeah, they will all reset.

instead of telling all the video players, just tell the one that is reacting to the video event " COMPLETE" by using " event.target" . i took out all the variable names, info, etc and tested it using JUST this code below, with 3 video players on the stage, each with an instance name "flvControl1" "flvControl2" and "flvControl3". it works fine this way:

import fl.video.*;

// Loop the video when it completes
function completeHandler(event:VideoEvent):void

{
<b>event.target.seek(0);
event.target.play() </b>
}

flvControl1.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl2.addEventListener(VideoEvent.COMPLETE, completeHandler);
flvControl3.addEventListener(VideoEvent.COMPLETE, completeHandler);

// Set video
flvControl1.source = "Statue.flv";
flvControl2.source = "Bush.flv";
flvControl3.source = "Clouds.flv";


hope that helps - let us know ....


Return to posts index

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