A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Looping FLV (event:NetStatusEvent) trigger??

  1. #1
    Junior Member
    Join Date
    Oct 2009
    Posts
    13

    Looping FLV (event:NetStatusEvent) trigger??

    Any ideas why my function "replicaLoop" doesn't run??
    I'm sure the function will work but it's not running
    :-(


    var replicaConnection:NetConnection = new NetConnection();
    replicaConnection.connect(null);
    var replicaStream:NetStream = new NetStream(replicaConnection);
    replicaStream.play("replica.flv");
    var replicaListener:Object = new Object();
    //replicaListener.onMetaData = onMetaData;
    replicaStream.client = replicaListener;
    var replicaVideo:Video = new Video();
    replicaVideo.attachNetStream(replicaStream);
    addChild(replicaVideo);

    function replicaPosition():void
    {
    replicaVideo.y = 17;
    replicaVideo.x = 20;
    replicaVideo.width = 510;
    replicaVideo.height = 286;
    }
    replicaPosition();



    function replicaLoop( event:NetStatusEvent ) :void
    {
    trace("working??");
    if(event.info.code == "NetStream.Play.Stop")
    replicaStream.seek(0);
    }

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    If the stream is stopped, you cannot seek. Use replicaStream.play(0)

  3. #3
    Junior Member
    Join Date
    Oct 2009
    Posts
    13
    That's not really the point...
    I've seen a few posts where people claim this code has worked fine for them but my function isn't running.

    function replicaLoop( event:NetStatusEvent ) :void
    {
    trace("working??");
    if(event.info.code == "NetStream.Play.Stop")
    replicaStream.seek(0);
    }

    This isn't tracing so it's not running the function. I was led to believe it would be triggered by the incoming netStream but that's not the case.

  4. #4
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    You need to add and event listener to your NetConnection object and point to replicaLoop as your handler.

    Code:
    var replicaConnection:NetConnection = new NetConnection();
    replicaConnection.connect(null);
    replicaConnection.addEventListener(NetStatusEvent.NET_STATUS, replicaLoop);
    var replicaStream:NetStream = new NetStream(replicaConnection);
    http://livedocs.adobe.com/flash/9.0/...xamplesSummary
    Last edited by jAQUAN; 11-06-2009 at 11:20 AM.

  5. #5
    Senior Member
    Join Date
    May 2008
    Posts
    332
    Here's a version that seems to work well for me. It traces when video is complete, then seeks back to where ever you want and will pause or play from there:
    Code:
    ns.onStatus = function(info) {	
    		if(info.code == "NetStream.Play.Stop") {
    			trace("Video complete")
      			ns.seek(5);
    			ns.pause();
    		}
    	}
    Best wishes,
    Eye for Video

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center