Take the 2-minute tour ×

I've searched most of the day for this answer, but found more questions than answers.

I have a .exe fullscreen flash app that loads video files (and many other things) through an external source. Everything links up okay, except that when the video plays, it often cuts out and just stops playing. Where it stops playing is random. Sometimes it's under 2 seconds, sometimes it will go for 30 seconds, but never has it made the full 58 seconds of the video.

I have traced the bytes loaded to the total and they match (it's a locally referenced file, no web).

Here's the code. If there's a better way to do this (that doesn't involve a class), please help.

    function loadCaseVideo(sourceVideo:String):void {
//sourceVideo = reference link from XML data
        var videoLoadedAlready:Boolean;
    NetConnection.defaultObjectEncoding = flash.net.ObjectEncoding.AMF0;
    var mNetConnection:NetConnection=new NetConnection();
    var mNetStream = new NetStream(mNetConnection);
    var video = new Video();
    video.width = 728;
    video.height = 522;
    video.y = 0;
    video.x = 0;


    mNetStream.client=new Object();
    mNetStream.addEventListener(NetStatusEvent.NET_STATUS, onNetStreamStatusEvent);

    function onNetStreamStatusEvent(event:NetStatusEvent):void 
            if (event.info.code == "NetStream.Play.Start") 
                //trace(mNetStream.bytesLoaded +", " + mNetStream.bytesTotal);
            if (event.info.code == "NetStream.Play.StreamNotFound") 
                    //trace("Video Not Found");     
            if (event.info.code == "NetStream.Buffer.Flush")
//I saw this being called so I ran a trace on it, these two are equal, meaning fully loaded?
                trace('loaded: '+ mNetStream.bytesLoaded +", total: " + mNetStream.bytesTotal);

    function onMetaData(metadata:Object):void

share|improve this question

1 Answer 1

I was able to resolve this by:

  1. Stripping everything back out
  2. Adding an FLVPlayback Object to my movieclip (that held the layout)

calling this function when the timeline reached this frame:

function loadCaseVideo(sourceVideo:String):void {
    videoHolder.videoPlayer.width = 728;
    videoHolder.videoPlayer.height = 522;
    videoHolder.videoPlayer.x = 0;
    videoHolder.videoPlayer.y = 0;
    videoHolder.videoPlayer.fullScreenTakeOver = false;
    videoHolder.videoPlayer.scaleMode = "exactFit";
    videoHolder.videoPlayer.source = sourceVideo;

When NOT DEALING WITH STREAMING WEB, this seemed to be the best way to do this. I had tried to use this component first, but at that time I was also resolving why f4v wasn't working - which was because I was in an older version of Flash. Once I was using CS5, the component worked for me as expected with f4v's.

  • Desktop only
  • Dynamic sources ok
  • If your app is fullscreen, make sure you set fullScreenTakeOver to false or the video will fullscreen in your app.
share|improve this answer

Your Answer


