FORUMS: list search recent posts

Loop Video with AS3

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Tom Slattery
Loop Video with AS3
on Dec 9, 2008 at 2:30:09 pm

Hi!

I'm trying to loop an FLV using Actionscript 3. Please do tell!

Thanks!
~TPS



Return to posts index

pieter helsen
Re: Loop Video with AS3
on Dec 9, 2008 at 3:51:31 pm

Using... what? :) NetStream? FLVPlayback component?

Using Netstream:

my_netstream.seek(0);
my_netstream.play(my_flv_url);


Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

Tom Slattery
Re: Loop Video with AS3
on Dec 9, 2008 at 3:53:49 pm

Right now I'm using an FLV playback, but I'm open minded ;)

Thanks!
~TPS



Return to posts index


Jen deHaan
Re: Loop Video with AS3
on Dec 9, 2008 at 6:18:28 pm

I have video looping code in an FLA linked on this blog post, http://flashthusiast.com/2008/11/18/motion-source-fla-files-for-max-present... (you can see the looping video in the SWF - it's the rain).

Download http://flashthusiast.com/wp-content/uploads/2008/11/car-rain.fla if you want the FLA example.

This is the code that loops a loaded FLV in a video object created with AS3:

//load the rain FLV
var video:Video = new Video();
addChild(video);

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

var ns:NetStream = new NetStream(nc);
ns.client = {onMetaData:ns_onMetaData, NetStatusEvent:ns_onPlayStatus};

video.attachNetStream(ns);
ns.play("your-video.flv");

function ns_onMetaData(item:Object):void {
// Resize video instance.
video.width = item.width;
video.height = item.height;
// Center video instance on Stage.
video.x = (stage.stageWidth - video.width) / 2;
video.y = (stage.stageHeight - video.height) / 2;
}

//loop the video
function ns_onPlayStatus(event:NetStatusEvent):void {
if(event.info.code == "NetStream.Play.Stop"){
ns.seek(0);
}
}
ns.addEventListener(NetStatusEvent.NET_STATUS, ns_onPlayStatus);

It creates a video object with AS3. There might be a better way, but it worked for that example :)

Jen.

-----
Jen
http://www.flashthusiast.com


Return to posts index

Tom Slattery
Re: Loop Video with AS3
on Dec 9, 2008 at 6:26:23 pm

That did it! Thanks!

~TPS


Return to posts index

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