time (NetStream.time property)

public time : Number [read-only]

The position of the playhead, in seconds.

Availability: ActionScript 1.0; Flash Player 7 - Note: This property is also supported in Flash Player 6 when used with Flash Media Server. For more information, see the Flash Media Server documentation.

Example

The following example displays the current position of the playhead in a dynamically created text field called time_txt. Select New Video from the Library options menu to create a video object instance, and give it an instance name my_video. Create a new video object called my_video. Add the following ActionScript to your FLA or AS file:

var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
my_video.attachVideo(stream_ns);
stream_ns.play("video1.flv");
//
stream_ns.onStatus = function(infoObject:Object) {
    statusCode_txt.text = infoObject.code;
};

this.createTextField("time_txt", this.getNextHighestDepth(), 10, 10, 100, 22);
time_txt.text = "LOADING";

var time_interval:Number = setInterval(checkTime, 500, stream_ns);
function checkTime(my_ns:NetStream) {
    var ns_seconds:Number = my_ns.time;
    var minutes:Number = Math.floor(ns_seconds/60);
    var seconds = Math.floor(ns_seconds%60);
    if (seconds<10) {
    seconds = "0"+seconds;
    }
    time_txt.text = minutes+":"+seconds;
}

If your SWF file includes a version 2 component, use the version 2 components' DepthManager class instead of the MovieClip.getNextHighestDepth() method, which is used in this example.

See also

bufferLength (NetStream.bufferLength property), bytesLoaded (NetStream.bytesLoaded property)


Flash CS3