Lives On Board

/ My MetaSphere /

Wed Feb 4, 2004

Flash MX Hosting
Web Hosting
Web Tools
Help FAQ
Site Chat
Web Search
Asheville NC
Network Log
Got Flash?
Web Links

Need Help?
We are online if image is green.
We are online if this image is green. Click here to chat live with

Linux Web Hosting

Flash Hosting with MetaSphere

Today in History:
1941: The United Service Organizations, popularly known as the USO, was chartered.
Asheville, NC
Help/FAQ Index / Search
Previous Page in Help/FAQ Tour Next Page in Help/FAQ Tour
Return to Main Page in Help/FAQ

Retrieving FLV length via ActionScript

If you want to retrieve the length of your streamed FLV file, you've got some work to do. The only way you can retrieve this value via Flash is by calling a server-side ActionScript. Once you master ServerSide ActionScripting in Flash, you will be considered an MX Jedi. Tons of new features and trick will be at your disposal. To get you started, we'll be retrieving the length of our Flash streamed movie file "timescape.flv". This flv file should be uploaded to the FCS server. Place it inside of UserName/streams/video/timescape.flv. Two seperate pieces we'll be building here. The Flash swf file which displays the movie to your audience, and the backside server ActionScript. The ActionScript is called "main.asc". FCS automatically looks for this file when your app starts. There is no need to call or require or load main.asc in your swf app. By uploading it to your UserName directory, it is called by all of your FCS applications automatically.


Here's the client-side ActionScript. This code goes in your swf file. Because you are using absolute paths to your UserName folder, you can run/publish this swf from anywhere. Even locally to help you learn. All that is required on the main stage is a dynamic textbox called output. Make it multilined so you cann see what the server is saying. You can also place a new blank embedded video object on the Stage if you want. This will actually play the movie timescape.flv. This is not neccessary but it looks pretty. Name the new video object you created "MyVideo". Of course to run this example, you will also need to make an FLV file (see above).

//In frame 1 of the main stage of your movie.
#include ""
app_nc=new NetConnection();
NewStream=new NetStream(app_nc);

function setupStream(nc){
myStream = new NetStream(nc);
output = output+"CALL getLength"+newline;
myStream = {};
myStream.onResult = function(streamLength){
output = streamLength;
};"getLength", myStream, "timescape");
app_nc.onStatus = function(info){
output = output+"onStatus="+info.code+newline;
if(info.code == "NetConnection.Connect.Success"){
output = output+"Setupstream"+newline;


On the server, you will need the following script inside of your main.asc file. Below is a working example of main.asc. Place this file in your UserName folder. Make sure it is called "main.asc". This file is expandable also. You can add your own Client.prototype calls. See your ActionScript Ref Guide for the 50 or so server-side Jedi tricks.

application.onAppStart = function(){
trace("::: Application has started :::");
application.onConnect = function(client){
Client.prototype.getLength = function(streamName){
trace("gettingLength of"+streamName+":"+Stream.length(streamName));
return Stream.length(streamName);

Refresh / Add Page to favorites/bookmarks.