FMS Issue

Hey,

i am connecting to a FMS and streaming a f4v. The connection is fine and at times the video plays fine as well. problem is that about 50% of the time, the flash player crashes if it running on a browser. Just viewing the swf file locally never causes any issue, only in the browser I have this issue.

Here is the sample code i am using to iron out issues before plugging it in the larger app


var nc:NetConnection;
var stream:NetStream;
var vid:Video = new Video(stage.stageWidth, stage.stageHeight);
var path:String;
var videoPath:String;
var clientObject:Object = new Object();

stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;

var cover:MovieClip = new MovieClip(); 

var getPath:URLLoader = new URLLoader(new URLRequest("path.txt"));
getPath.addEventListener(Event.COMPLETE, _pathLoaded);

var getVideoPath:URLLoader = new URLLoader(new URLRequest("videoPath.txt"));
getVideoPath.addEventListener(Event.COMPLETE, _videoPathLoaded);

function _videoPathLoaded(e:Event):void
{
    videoPath = getVideoPath.data as String;
}

function _pathLoaded(e:Event):void
{
    path = getPath.data as String;
    beginTransaction();
    tracer.text = "Connecting to server" + " " + path;
}


function beginTransaction():void
{
    nc = new NetConnection();
    nc.connect(path);
    nc.addEventListener(NetStatusEvent.NET_STATUS, _checkConnection);
    nc.addEventListener(IOErrorEvent.IO_ERROR, _handleError);
}

function _handleError(e:Event):void
{
    tracer.text = "Unable to connect to server."
}

function _checkConnection(e:NetStatusEvent):void
{
    if(e.info.code == "NetConnection.Connect.Success")
    {
        
        connectToVideo();
    }
    else
    {
        tracer.text = e.info.code + " .Server refusing connection";
    }
}

function connectToVideo():void
{
    tracer.text = "connected to server, trying to stream video " +videoPath+ " Make sure this file exists in the server";
    stream = new NetStream(nc);
    clientObject.onMetaData = onMetaData;
    stream.client = clientObject;
    vid.attachNetStream(stream);
    
    
    
    
    
    stream.bufferTime = 5;
    stream.play("mp4:intro.f4v");
    stream.pause();
    
    stream.addEventListener(NetStatusEvent.NET_STATUS, _update);
    stage.addEventListener(MouseEvent.CLICK, resume);
    
}

function resume(e:MouseEvent):void
{
    
    stream.resume();
    stage.addChild(vid);
    vid.width = stage.stageWidth;
    vid.height = stage.stageHeight;
    stage.addChild(tracer);
    
}




function onMetaData(onMet:Object):void
{
    tracer.text = onMet.info;
}

function _update(e:NetStatusEvent):void
{
    if(String(e.info.code) == "NetStream.Play.Start")
    {
        stream.pause();
    }
    else if(String(e.info.code) == "NetStream.Buffer.Full")
    {
        stream.resume();
    }
    else if(stream.bufferLength <= stream.bufferTime)
    {
        stream.pause();
    }
                          
                              
    tracer.text = String(e.info.code);
}


Am i doing something wrong? I have no idea why the browser should crash. I am publishing with the flash cs4 compiler targeting player 10.