A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: I want looping flv's!!!

  1. #1
    Senior Member
    Join Date
    May 2000
    Posts
    814

    I want looping flv's!!!

    i have got as far as i can with the following code. I'm playing multiple flv's, (which are loaded from an xml file) with success. All i want to do is to keep them looping, i cant work this out as i'm an AS3 newbie!

    PHP Code:
    var nc:NetConnection;
    var 
    ns:NetStream;
    var 
    listener:Object;
    //
    //


    var xml:XML = new XML();
    var 
    loader:URLLoader = new URLLoader();
    loader.load(new URLRequest("tubePanelsVID.xml"));

    loader.addEventListener(
        
    Event.COMPLETE,
        function(
    evt:Event):void {
            
    xml XML(evt.target.data);
            
                
    populatePics ();

                }
    );
            



    function 
    populatePics ():void {
        
    //This will be used to represent a menu item
        
    var picItem:PicItem;
        
    //Counter
        
    var i:uint 0;
        

                  
        
    //Loop through the links found in the XML file
        
    for each (var link:XML in xml.links.link) {

            
    picItem = new PicItem();
            
    //picItem.id = i;

            //trace(link.@panel);
            
            
            //Insert position
            
    picItem.73 i255;
            
    picItem.667 i* -127;


            
    picItem.filters = [shadows];

            
    addChildAt(picItem,1);
            
            
    loadVid(link.@panelpicItem.myVideo);


            
    i++;

        }
    setChildIndex(goingUp,numChildren 1);

    }

    function 
    loadVid(s:Stringmc:Object):void {
        
    trace(s)

        
    nc = new NetConnection();
        
    nc.connect(null);
        
    ns = new NetStream(nc);
        
    mc.attachNetStream(ns);
        
    listener = new Object();
        
    listener.onMetaData onMeta;
        
    ns.client listener;

        
    ns.play(s);
    }

    function 
    onMeta(data:Object):void {
        
        var 
    totalLength:Number data.duration;
    trace(totalLength);


    I would love a few tips on this to help me along my AS3 journey!

    cheers
    rat

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Here's a workaround...detecting the end of the video and calling play() takes a while so it usually produces a noticeable skip in the looping - to get around that, listen for the playhead updates and just seek back to the beginning when you get close to the end. The trouble is that if your swf drops a few frames at the wrong moment you could miss the update and hit the end anyway so it's still necessary to watch for restarts.

    PHP Code:
    _v.autoRewind true;
    _v.addEventListener(VideoEvent.PLAYHEAD_UPDATEvidLoop);
    _v.addEventListener(VideoEvent.AUTO_REWOUNDrestart);

    private function 
    vidLoop(e:VideoEvent):void{
        if(
    _v.totalTime e.playheadTime .05_v.seek(0);
    }

    private function 
    restart(e:VideoEvent):void{
        
    _v.play();


  3. #3
    Senior Member
    Join Date
    May 2000
    Posts
    814
    i couldn't get the VideoEvent code to work with my example, now i have taken 2 steps forward but having to take a step back, purly as i do not know AS3.

    i just want to reload the flv's on the switch statement at the bottom of my code, it seems simple but i havn't had any luck!!!

    PHP Code:
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.filters.DropShadowFilter;
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;


    var 
    shadows:DropShadowFilter = new DropShadowFilter();
    shadows.distance 3;
    shadows.angle 45;
    shadows.alpha 0.5;
    shadows.blurX5;
    shadows.blurY5;

    var 
    nc:NetConnection;
    var 
    ns:NetStream;


    var 
    xml:XML = new XML();
    var 
    loader:URLLoader = new URLLoader();
    loader.load(new URLRequest("tubePanelsVID.xml"));

    loader.addEventListener(
        
    Event.COMPLETE,
        function(
    evt:Event):void {
            
    xml XML(evt.target.data);
            
                
    populatePics ();

                }
    );
            



    function 
    populatePics ():void {
        
    //This will be used to represent a menu item
        
    var picItem:PicItem;
        
    //Counter
        
    var i:uint 0;
        
        
    //Loop through the links found in the XML file
        
    for each (var link:XML in xml.links.link) {

            
    picItem = new PicItem();
            
    //picItem.id = i;
            
            //Insert position
            
    picItem.73 i255;
            
    picItem.667 i* -127;


            
    picItem.filters = [shadows];

            
    addChildAt(picItem,1);
            
            
    loadVid(link.@panelpicItem.myVideo);

            
    i++;

        }
    setChildIndex(goingUp,numChildren 1);

    }



    function 
    loadVid(s:Stringmc:Object):void {
        
        
    nc = new NetConnection();
        
    nc.connect(null);
        
    ns = new NetStream(nc);
        
    mc.attachNetStream(ns);
        
    ns.addEventListener(NetStatusEvent.NET_STATUSonStatusEvent);

    ns.client meta;
    ns.play(s);

    }


    var 
    meta:Object = new Object();
    meta.onMetaData = function(meta:Object) {
        
        
    trace(meta.duration);
    }




    function 
    onStatusEvent(event:NetStatusEvent):void {
       
        switch (
    event.info.code)
        {
            case 
    "NetStream.Play.Start":
                
    trace("Start [" ns.time.toFixed(2) + " seconds]");
                break;
            case 
    "NetStream.Play.Stop":
                
    trace("Stop [" ns.time.toFixed(2) + " seconds]");
                
                break;
        }
        


  4. #4
    Senior Member
    Join Date
    May 2000
    Posts
    814
    still stuck, is it far from getting a result!
    should i not be using the
    PHP Code:
    function onStatusEvent(event:NetStatusEvent

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