A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: time display on flv player question

  1. #1
    Senior Member
    Join Date
    Oct 2001
    Location
    Cleveland Ohio
    Posts
    216

    time display on flv player question

    Hello,
    I am building a flv player with time display.

    Here is the code I am using:

    Code:
    // event listener for changing the time display
    
    
    
    function updateNP(event:Event):void {
    	// time code code...
    	var totalSeconds:Number = theplaya.playheadTime;
    	var totalSeconds2:Number =  theplaya.totalTime;
    	var minutes:Number = Math.floor(totalSeconds /60);
    	var minutes2:Number = Math.floor(totalSeconds2 /60);
    	var seconds = Math.floor (totalSeconds) % 60;
    	var seconds2 = Math.floor (totalSeconds2) % 60;
    	if (seconds < 10){
    		seconds = "0" + seconds;
    	}
    	if (seconds2 < 10){
    		seconds2 = "0" + seconds2;
    	}
    	timeBox.text =  minutes + ":" + seconds + " / " +  minutes2 + ":" + seconds2;
    	
    }
    this.addEventListener (Event.ENTER_FRAME, updateNP);
    When the player first loads the video the total time is displayed as "NaN" before it gets the length information. How can I set the initial value to "0:00" instead of having "NaN" displayed?

    I tried setting the value at the top of my actionscript (before the previously listed event handler) to:
    Code:
    timeBox.text =  "0:00 / 0:00";
    But it still listed the totaltime as NaN before it displays the actual length.

    Thanks,
    mperla
    Computers Hate Me!!!!
    Rock the Vote!!!!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You can do something like this. Place the script under the timeBox line;
    if(timeBox.text.substring(0,3)=="NaN")
    {
    timeBox.text="00:00";
    }
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Try this for your first two lines:

    PHP Code:
        var totalSeconds:Number = (isNaN(theplaya.playheadTime)) ? theplaya.playheadTime;
    var 
    totalSeconds2:Number = (isNaN(theplaya.totalTime)) ? theplaya.totalTime

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