How to preload FLV video in flash with actionscript 2.0

team_vid

Since the introduction of Flash video (flv) in 2002, Flash Player has become the most widely installed Internet video client, running on over 96% of all Internet-connected PCs. The ubiquity of Flash Player ensures that most visitors can view Flash video without downloading additional plug-ins, so you can reach more people with lower development, testing, and support costs.

Flash video can be delivered either via a streaming server, which allows for on-demand/live video, or via the more commonly used progressive download method. Progressively downloaded videos do not start until a proportion of the video has downloaded to the client, ensuring a smooth un-interupted video experience.

While this is fine and dandy, what happens when you want the entire video to download before it begins to play, or if you have several bandwidth intensive videos as is the case of our own “Meet the Team” page. In either case, preloading flv’s is not a documented feature, and it must therefore be simulated.

What follows is one method you can use to simulate preloading Flash video files, including a progress bar and percentage label.

/**
* Preloading FLVs with progressbar
*
* Actionscript developed by Bloom Media Ltd. | www.bloommedia.co.uk
* Contributors: Dominic Kelly
*/

// open a net connection
var nc:NetConnection = new NetConnection();
// null connection for progressive download
nc.connect(null);

// create a stream
myNetStream = new NetStream(nc);
myVideo.attachVideo(myNetStream);
// load video
myNetStream.play("dom-kelly.flv");
// pause video to hide it from the stage
myNetStream.pause();

// hide load progress
percentage._visible = false;
percentage._visible = false;

// resize video onload, based on meta data
myNetStream.onMetaData = function(obj)
{
	myVideo._height = obj.height;
	myVideo._width = obj.width;
	// show load progress
	percentage._visible = true;
	percentage._visible = true;
};

// listen for the 'Stop' status event, and restart the video to loop it
myNetStream.onStatus = function(info)
{
	if (info.code == "NetStream.Play.Stop")
	{
		this.seek(0);
	}
};

// create a preload interval to check load progress every 1 millisecond
myInterval = setInterval(checkBytesLoaded, 1, myNetStream);

// preload loop progress
function checkBytesLoaded(mns)
{
	// calculate percentage of video that has downloaded
	pctLoaded = Math.round(mns.bytesLoaded / mns.bytesTotal * 100);

	// update textfield on the stage
	percentage.text = pctLoaded + "%";

	// update progress bar on the stage
	progressBar._xscale = pctLoaded;

	if (pctLoaded >= 100)	{
		// the video has fully downloaded
		_root.percentage.text = "loaded";
		// play video from the beginning
		mns.seek(0);
		mns.play("dom-kelly.flv");
		// clear interval
		clearInterval(myInterval);
	}
}

And there you have it, a simple and effective flv preloader.

View the demo or download the source code.

Be Sociable, Share!
This entry was posted in Technical and tagged . Bookmark the permalink.

81 Responses to How to preload FLV video in flash with actionscript 2.0

  1. oliver says:

    nice tut, but i have got a question,
    how do i stop the video from looping?

    • Steve says:

      Thank you very much for the FLV preloader – looked everywhere – yours is the best!
      One more favor if you could – how can I add a “go to URL” to your script once the video is done playing?

      This is what I had earlier that worked:
      ——————————-
      import fl.video.VideoEvent;

      myVideo.addEventListener(VideoEvent.STOPPED_STATE_ENTERED, onVideoStopped);

      function onVideoStopped(evt:VideoEvent):void
      {
      var url:URLRequest = new URLRequest(“http://url.html/”);
      navigateToURL(url, “_self”);
      }
      ————————-
      Thanks again!

  2. @Oliver

    “nice tut, but i have got a question, how do i stop the video from looping?”

    To stop the video from looping, simply remove the following lines of code:

    // listen for the ‘Stop’ status event, and restart the video to loop it
    myNetStream.onStatus = function(info)
    {
    if (info.code == “NetStream.Play.Stop”)
    {
    this.seek(0);
    }
    };

  3. fltofx says:

    Hi,
    Thanks for the tutorial.
    And i want to ask
    1)how we can preload the each buffering segment of video with out loading total video.Like it’ll preload part of the video and play then again the preloader appears..

    2)How can we start the buffering at a point where user drag on the seek bar.Like you tube does?

    Thanx again and hope u reply

  4. @fltofx:

    “1) how we can preload the each buffering segment of video with out loading total video. Like it’ll preload part of the video and play then again the preloader appears.”

    You will require a streaming server, such as Flash Media Server.

    “2) How can we start the buffering at a point where user drag on the seek bar.Like you tube does?”

    Again a streaming server is required for this. Progressive video loads frame-by-frame, and as such it is impossible to seek to a certain position in a video *before* it has loaded.

  5. Jerry says:

    Should this action script be applied to the same frame that the video clip is on or on a different frame or layer?

  6. @Jerry

    “Should this action script be applied to the same frame that the video clip is on or on a different frame or layer?”

    This should not matter, so long as a) the flash video object is present on the stage *before* any of the code above is called, and b) the path to the video object in the code is valid, i.e. if you decided to place the video object inside a new MovieClip “video_mc” then the path would be:

    video_mc = myVideo.attachVideo(myNetStream);

    It is best practice to have all your ActionScript in the first frame (and the top layer) of your fla, or placed in an external .as file.

  7. nice tutorial. Is AS2 better then AS3? I’m gonna try this tomorrow, thanks so much!

    Mark

  8. admin says:

    @ Mark

    “nice tutorial. Is AS2.0 better then AS3.0? I’m gonna try this tomorrow, thanks so much!”

    That’s a tough question, and the answer is it really depends on the project!

    AS3 is more consistent as a language which makes it easier to code, it is up to 10 times faster according to Adobe and it is much better at handling events and working with display objects. For a full feature set you can check out Adobe’s ActionScript 3.0 overview.

    In my opinion, the advantages of AS3.0 can be at the detriment of development time, I find that AS3.0 can require more code than AS2.0 to achieve the same result. This may be because AS3.0 is still relatively new to me, and I still need to get my head around it fully.

  9. Jesus says:

    Hi, I am trying to do the same, a FLV preloader but in Actionscript 3.0, any chance you could guide me? I just need to know which classes are the equivalent to the ones used in AS 2.0 since I am not familiar with AS 3.0 at all.

    Thanks!

  10. Hi Jesus. You could try a AS2.0 to AS3.0 converter. While this will not be entirely accurate, it will give and idea of which AS3.0 classes you should be using.

  11. djin says:

    i tried using this code with the mediadisplay component but it doesn’t work. will the code above work for that particular component or do i need to edit the code above?

  12. @djin: My example uses the FLVPlayback component which sits in Video > FLVPlayback.

    Media > I suspect media > MediaDisplay has a different set of methods (although I rarely use it), and so the code above will most likely not work without substantial modification.

  13. djin says:

    @dominic
    ok thanks. I’ll just use the flvplayback then. salamat!!

  14. djin says:

    another thing again :D

    regarding this code:
    myNetStream.play(“dom-kelly.flv”)

    1. can i just put the flv filename on the content path on the component inspector for flvplayback?

    2. will this code work in conjunction with a separate listener event? the listeneer event is used for checking whether the movie has finished playing so that i will be able to activate another movieclip.

  15. @djin

    1. can i just put the flv filename on the content path on the component inspector for flvplayback?

    You could try it! I try to do either everything in code, or everything in the component inspector, I don’t like mixing things up as it can get confusing later.

    2. will this code work in conjunction with a separate listener event? the listeneer event is used for checking whether the movie has finished playing so that i will be able to activate another movieclip.

    // listen for the ‘Stop’ status event, and restart the video to loop it
    myNetStream.onStatus = function(info)
    {
    if (info.code == “NetStream.Play.Stop”)
    {
    this.seek(0);
    }
    };

    This already checks to see whether the movie has stopped? So instead of this.seek(0); you could could add code to load a second movieclip?

  16. djin says:

    i hope i am not annoying you with my questions but i looked at the component panel and looked at the video>flvplayback, yours looks different from the one on flash cs3. yours is white with an x on the middle while the one on flash cs3 has a black bg with lots of skins.

    did you customize the flvplayback component?

  17. djin says:

    i also have another question regarding this code:

    // create a preload interval to check load progress every 1 millisecond
    myInterval = setInterval(checkBytesLoaded, 1, myNetStream);

    // preload loop progress
    function checkBytesLoaded(mns)

    how does the function checkBytesLoaded(mns) get data from

    // create a preload interval to check load progress every 1 millisecond
    myInterval = setInterval(checkBytesLoaded, 1, myNetStream);

    when there is no data being sent to checkByteLoaded?

  18. @dji -

    1.

    did you customize the flvplayback component?

    You know what, you’re right” I think I confused myself here with the all talk of components :)

    I’ve used the AS2.0 video object to bind the video, not a the flvplayback component. To create a video object have a look at this screenshot:

    http://jing.bloommedia.co.uk/capture/2008-12-18_0930.png (click where the arrow is pointing and choose Actionscript controlled video).

    2.

    // preload loop progress
    function checkBytesLoaded(mns)

    how does the function checkBytesLoaded(mns) get data from

    // create a preload interval to check load progress every 1 millisecond
    myInterval = setInterval(checkBytesLoaded, 1, myNetStream);

    when there is no data being sent to checkByteLoaded?

    Ok, so what happens is:

    myInterval = setInterval(checkBytesLoaded, 1, myNetStream);

    A variable myInterval is created to hold the setInterval() method. setInterval() takes 3 parameters – a function, a time, and an object. The role of setInterval() is to call a specified function over a specified period of time in milliseconds, and optionally an object can be passed (in this case the video).

    checkBytesLoaded(mns)

    So, every 1 millisecond, the checkBytesLoaded function above is called which has a parameter “mns”. mns tands for MyNetStream, and in this case is the video object. Further in the function we can access bytesLoaded property of mns, i.e.

    mns.bytesLoaded

    Hope that makes sense!

  19. djin says:

    hello dominic!

    now i get it! thank you very much for your wonderful explanation and the idea for preloading flv!

  20. djin says:

    hello dominic i am back with another question :D i hope you don’t mind again.

    i tried using the preloading code and the AS2.0 video object. i had 4 videos to preload but a problem came up. as2.0 video object will just let me use it for 2 times. after that the blue box becomes red.

    AS2.0 video object can only be used twice?

    cuz i was going to use it on a project with 4 different flv files sitting on different scenes. if a user clicks on a button it goes to a specific scene where a specific video would be preloaded and then played to a the as2.0 video object.

    but once i get to the 3rd scene and copying an instance of the as2.0 video object from the library by dragging it turns red and once you run the whole file and click on button and takes you to the specific scene. it jsut goes to 0% loaded all the time even if i test it on my local machine.

    it will work though if you delete the 3rd as2.0 video object from the 3rd scene.

  21. djin says:

    hello again dominic!

    never the question i posted above. i found the answer. it was an operator error on my part :D sorry! thanks again for your help.

  22. @djin: Not a problem, I’m happy I could help :)

  23. Eric says:

    Thank you so much!

  24. k.Lo says:

    When I tried to open the .fla file it gave me an error saying “Unexpected file format”. I’m using Flash 8 Professional.

  25. k.LO: You will need to upgrade to at least Adobe Flash CS3. CS4 is available on a time limited trial from http://www.adobe.com.

  26. Pingback: Preloading FLVs in flash with ActionScript 2.0 | Psyked

  27. RRZ says:

    I’ve got this mostly working and testing it on a very slow connection, although, after it has downloaded 100% the FLV stutters through very slowly so I’m not sure whether I have got the FLV actually preloading.

    I’m wondering whether this has anything to with it – as you explained to Djin, how is ‘mns’ linked to ‘myNetStream’? How does ‘mns’ become ‘myNetStream’?

    Thanks

  28. RRZ says:

    I think I may have answered the question of the FLV struggling to play on a very slow connection – as you said, preloading is not a documented feature so this is a simulation and the FLV will still play at the bit rate for which it was encoded. I encoded a lower rate 150kbps FLV and saw a slight improvement but there is probably no solution to this for a modem connection, which I think is the speed I was testing on.

    I would still be grateful to understand a bit more about how ‘mns’ is connected to ‘myNetStream’ if possible.

    Thanks for your time on this.

  29. Dominic Kelly says:

    Hi RRZ. I’m not sure connection speed will play any part of this problem. FLV’s are cached to the local file system, and as such once they have ‘preloaded’ or played once, they should, in theory, play without stutter every time.

    Have you tried a different machine? I know the codec that flash uses is particularly GPU intensive, so older machines may not be up to the task.

  30. RRZ says:

    Thanks for your reply and the info.

    I encoded two FLVs for Flash Player 7 medium quality and low quality, and I am working/testing on an Apple Mac PPC Dual 2Ghz, circa 2005, so I don’t know if either the Sorenson codec or my system GPU have anything to do with this.

    I’ll take the opportunity to test the FLVs when I am around another system.

    Thanks again.

  31. RRZ says:

    PS.

    GPU is a GeForce 6800 GT, 256 Mb Ram

  32. Joe88 says:

    Hi,

    The quality of the flash player is good. I used one of it i liked it very interesting.

    joe

  33. cc says:

    hi, great tutorial here. thanks. ok so… after my flv loads (100%) I want the loader bar to go away! how do I do that?

    • Hi there. You could try adding:

      _root.progressBar._visible = false;

      e.g.

      if (pctLoaded >= 100) {
      // the video has fully downloaded
      //_root.percentage.text = “loaded”;
      _root.progressBar._visible = false;
      // play video from the beginning
      mns.seek(0);
      mns.play(“dom-kelly.flv”);
      // clear interval
      clearInterval(myInterval);
      }

      I’ve not tested it, but it should do what you want :)

  34. Niels says:

    Hi there,

    is it possible to use this preloader for multiple flv’s?
    Cuz i’m searching for a preloader that loads 15 flv files at once..
    If some1 can help me with this, i would be very, very happy :)

    Greets

    • Hi there Niels. The quick answer is yes, you can absolutely do what you want, but unfortunately not without substantial modification I’m afraid.

      The way I did it on our meet the team page was to create an array of flv’s, run a loop to progromatically create new NetStream objects and then play/preload each flv individual. The code above contains most of what you need, but like I say it’s going to need quite a lot of tweaking! A few careful for loops is probably all you need.

      • Duda says:

        im desperated, the videos show up but doesnt play. what im doing wrong. i cant think any more, i need to create the vars dynamicly i think, but i cant think how.
        i really will apreciate your help if you could, the dead line for this project its tomorrow and im stuck.

        please please.
        thnks a million.

        function opennews() {
        newslist = new XML();
        newslist.load(“pv/pv.xml”);
        newslist.ignoreWhite = true;
        var item_spacing = 140;
        var item_cont = 1;

        condition = 1;

        loadingNews._alpha = 100;
        newslist.onLoad = function(success) {
        if (success) {

        if (this.getBytesLoaded() == this.getBytesTotal()) {

        var news:XMLNode = this.firstChild;
        numberOfItems = news.childNodes.length;
        pages = numberOfItems/6;

        for (i=0; i<numberOfItems; i++) {
        var link = news.childNodes[i].childNodes[1].childNodes[0].nodeValue;
        var TEXT:String = news.childNodes[i].childNodes[0].childNodes[0].nodeValue;
        var item_mc = pvHolder_mc.smallHolder_mc.attachMovie(“small_mc”, “small_mc”+i, i);
        item_mc._x = i*165.6;

        //loadFlv(link);
        //loadFlv2(link);

        var nc:NetConnection = new NetConnection();
        nc.connect(null);
        var ns:NetStream = new NetStream(nc);
        item_mc.videoPlayer.theVideo.attachVideo(ns);
        ns.play(link);

  35. Sarah says:

    Hi there,

    Hi there,

    I am VERY new to flash and have to preload a .fla file as part of an assigmnent for uni.

    I tried your code and got the following error message when I came to test it:

    Location:
    Scene=Scene1, layer=Layer1, frame=1, Line 59

    Description:
    Unexpected ‘gt’ encountered

    Source:
    if (pctLoaded >= 100) {

    What does this mean? Am I doing something wrong (probably lol!)
    (I am using Flash CS3)

    I inserted the code on the same frame as the video ‘symbol’ which was imported to the stage from the libary – it looks like a white rectangle with a blue border and green lines making a cross from the opposite corners.

    Hope this makes sense! Thank you :-)

    • Hi Sarah,

      Make sure line 59 is exactly this:

      if (pctLoaded >= 100)

      With an ‘greater than’ angled bracket, not something like this:

      if (pctLoaded & g t ; = 100)

      “& g t ;” is the encoded value for the greater than symbol. I’ve had to put spaces in here as the browser automatically renders it as a bracket!

      Have a look here for more information:

      http://www.w3schools.com/HTML/html_entities.asp

  36. Maralbjo says:

    Wonder why I couldn’t get the source files to work. The video simply doesn’t show up!

  37. Rav says:

    Great Tutorial, this helped me soooo much!

    I’ve got everything working but I have a question about audio control. I have a mute button on stage with the code:

    on (release){
    _root.myVideo.volume = (0)
    }

    The button switches out to a sound button that has similar code but set to “volume = (25)” to enable the audio again.

    Unfortunately it is not changing the volume level being played by myVideo. How do I reference myVideo in order to control the audio playing??

    Any help would be greatly appreciated.
    Thanx
    Rav

    Rav

    • Hi there. Glad you found it helpful! of the top of my head, you could try something like this:

      // create a new sound object, pass in myVideo object
      var audio_volume:Sound = new Sound(myVideo);

      // adjust the flv volume by 25
      audio_volume.setVolume(25);

      I’ve not tested this, but basically you should adjust volume via the setVolume method of the Sound object.

  38. KLarsen says:

    Hi, I really appreciate your preloader. What I am trying to do is to have the flash file go to the next frame once the video is complete. This is what I had before when I had it as a FLVPlayback component:

    stop();
    var listenerObject:Object = new Object(); // create listener object
    listenerObject.complete = function(eventObject:Object):Void {
    gotoAndStop(3);
    };
    myVideo.addEventListener(“complete”, listenerObject);

    Thank you!

    • Hi KLarsen, can you do something like this?

      // listen for the ‘Stop’ status event, and restart the video to loop it
      myNetStream.onStatus = function(info)
      {
      if (info.code == “NetStream.Play.Stop”)
      {
      this.seek(0);
      gotoAndPlay(100);
      }
      };

      Where gotoAndPlay(100) is the frame number you want to jump to after the flv has preloaded?

      • KLarsen says:

        Great! Thank you. That was exactly what I was looking for.

        When I load my site though, the preloader is not showing and it is simply still emptiness for a few moments. It doesn’t appear to be anything happening, then all of a sudden, it loads. Any ideas on what I might be doing?

        The actions are in Frame 1 right above the layer that the movie object is.

        • Hey again. Your problem could be due to many reasons. Ensure you are publishing your movie as Actionscript 2.0 for a start. Also, the fact that the preloader graphics aren’t loading, but the flv is is, tells me that the script is doing it’s job but it is perhaps not referencing the preload MC’s correctly. So, double check all your path’s. Hope that helps.

  39. Peter Cooper says:

    Hi Dominic,

    Seems like a great preloader, but unfortunately I cannot get it to work.
    I am using Flash CS4 (action script 2) and Dreamweaver CS4. I have converted a .mov file to a FLV file imported it into Flash using progressive FLVPlayback. I have your script above in the first frame and my video on a layer underneath I have substituted your “dom-kelly.flv” with “newintro.swf” because I am making a swf and importing it into Dreamweaver. Does all this sound ok or am I doing something wrong.

    • Hi Peter,

      “I have substituted your “dom-kelly.flv” with “newintro.swf” ”

      Can you try using .flv?

      • Peter Cooper says:

        Hi again Dominic

        .flv does not work either. It seems to be loading it, but the loading bar does not appear.
        When I import my video to the Library, it names it FLVPlayback I assume this is normal, in the script I am inserting the original name of the .flv is this correct.

  40. Pallav says:

    Hi Dominic,

    How to load multiple FLV’s files on preloading phase?

    Thanks you

  41. Geoff says:

    Hi Dominic,

    I have your script working with the preloader, the only problem is when the movie comes to play there is no image, just audio. I have tested the flv in other places and it works in other instances, I’ve also used a couple of different movies to test it, but nothing.

    Any ideas were I am going wrong?

    Cheers.

    • Hi Geoff,

      Considering that you have got it to work in some places tells me that there must be some conflict actually where you want it to be. That’s pretty hard to debug without seeing the code! Perhaps if you gave me a little more info I could help you out.

      Cheers.

  42. Howard says:

    Hi Dominic
    Thanks for the tutorial. I have got this to work using an AS2 Video object.
    Can this script be used to preload a FLVPlayback component, as opposed to an AS2 Video object? If so, what changes need to be made to the script?
    Reason being, I wanted to use the playback controls skin available in the FLVPlayback component.

    Otherwise, if I need to use a Video object to use this preloader, how do I add a playback controls skin to a Video object?

    Cheers H

  43. DC says:

    I’m curious as to multiple FLV’s being downloaded into a single player, I have no player controls on it, just an image based frame. I have a menu control bar,consisting of buttons that call each FLV, they are all progressive download.
    I would like these FLV files to load while my visitors are on the main page of the site so when they finally access the video page, the FLV they choose will launch automatically without a loading bar or a witing period. Most of these files are substanial in size and the bizarre part is, the largest file loads the first and fastest currently. One other detail I might mention is, the files all load into a level 2 swf, so there is no need of a stop button, when a user clicks to another section of the site all files auto rewind.

  44. Jason says:

    Hi there!

    Great tutorial, or code sharing, as it were.

    I am trying to add controls to the video after it loads. A simple play/pause button, a statusbar (for scrubbing video) and a volume control. I have tried everything, and I cant seem to get them to play. I have even tried listening for the stop command, and assigning my controls with something like myVideo.seekBar=my_seekBar; burt to no avail.

    Do you have any suggestions?

  45. Jason says:

    Dominic,

    How would I add a play/pause button, a seek bar, and audio controls after the movie loads? I cant seem to get it to work….

    Thanks!

  46. Paul Barrett says:

    Hi Dominic
    thanks for the tutorial stuff, hopefully you can help out a little further. I’m getting multiple clips to load fine if I hard code them in, ie::

    **********

    // open a net connection
    var nc:NetConnection = new NetConnection();
    // null connection for progressive download
    nc.connect(null);
    //
    // create a stream – attach it to a MC on the main timeline (myVideo)
    myNetStream = new NetStream(nc);
    myVideo.attachVideo(myNetStream);
    //
    myNetStream2 = new NetStream(nc);
    myVideo2.attachVideo(myNetStream2);
    // load video
    myNetStream.play(“1_intro_FL9_1024x576_website.flv”);
    myNetStream2.play(“2_homePageButtons_FL9_1024x576_website.flv”);
    // pause video to hide it from the stage (we can remove this to autostart)
    myNetStream.pause();
    myNetStream2.pause();

    *****

    then I use your percentage preloader which works fine also for the first clip. I’m using the stop listener to start the next clip (2) playing and hide the first one. This is all ok, but when I try to build a loop and load them from an array it just wont have it. My code looks like this:

    *****

    // create an array for the names of the video clips
    videoClipArray = new Array(“1_intro_FL9_1024x576_website.flv”, “2_homePageButtons_FL9_1024x576_website.flv”);
    // open a net connection
    var nc:NetConnection = new NetConnection();
    // null connection for progressive download
    nc.connect(null);
    //
    for (i=0; i<videoClipArray.length; i++) {
    // create a stream
    myNetStream[i] = new NetStream(nc);
    // duplicate the movie clip video component
    //this.myVideo.duplicateMovieClip(“myvideo”+i,i,{_x:0, _y:0});
    // attach it to an MC on the main timeline (myVideo)
    myVideo[i].attachVideo(myNetStream[i]);
    // load video
    myNetStream[i].play(videoClipArray[i]);
    // pause video to hide it from the stage (we can remove this to autostart)
    myNetStream[i].pause();
    // hide load progress
    percentage._visible = false;
    percentage._visible = false;
    //
    // resize video onload, based on meta data
    myNetStream[i].onMetaData = function(obj) {
    myVideo[i]._height = obj.height;
    myVideo[i]._width = obj.width;
    // show load progress
    percentage._visible = true;
    percentage._visible = true;
    };
    }

    ****

    I’m not getting any code errors, can you see what I might be doing wrong?

    Many thanks
    Paul

  47. TheBuzzer says:

    AS3 doesn’ recognize the onStatus function, I found the way to do it with listener…

    ns.addEventListener(NetStatusEvent.NET_STATUS, StatusNS);

    function StatusNS (eventNS:NetStatusEvent) {
    if (eventNS.info.code == “NetStream.Play.Stop”) {
    this.seek(0);
    // Or do something else like GotoPlay(100); or GetURL();
    }
    };

    I’m working to fix the onMetaData section for AS3, I’ll leave the code tomorrow!

    Marc

  48. Megadeth says:

    Hi, Thanks a lot for this tut’ ! Can we add in this case a skin (ClearOverPlaySeekMute.swf for example) to the flv ? Best regards, Mega ;)

  49. Megadeth says:

    Hi, Thanks a lot for this tut’ ! Can we add in this case a skin (ClearOverPlaySeekMute.swf for example) to the flv and how ? Best regards, Mega ;)

  50. Josh says:

    Hello,

    No sure if this is still active but i’m having problems going to the next frame. I have placed the above code (going to the next frame) however it just goes to the next frame and does play through the .flv.

    Any help would be great

    Cheers

  51. Rakesh says:

    Hello,
    how can I add a “go to URL” to your script once the video is done playing?
    this answer will be really helpful for me.
    Rakesh

  52. Rakesh says:

    hello Gyus,

    for getURL i did like this way and it works for me,

    first of all i put this code

    // listen for the ‘Stop’ status event, and restart the video to loop it
    myNetStream.onStatus = function(info)

    {
    if (info.code == “NetStream.Stop”)
    {
    this.seek(0);
    gotoAndPlay(700);
    }
    };

    there 700 is the frames when my movie will stop

    and then i went into frame no. 700 and put the getURL Scripts.

    Rakesh

  53. dino roselli says:

    hi it’s very intresting tuts, i wanna know how could i skyp to the next frame after the video is played…somebody could help me? thanks a lot

  54. Piotr says:

    hi, great job Dominic, I was searching for something like this many days, but I am new to Flash, I can not sort out how to redirect the page after intro stops playing, getUrl was mentioned twice in comments but it is still not sorted, could you plese tell me how the source code should look exactly and where it should be placed if I want to go to different url after intro stops playing? I removed “listen for the Stop status event” to not loop, but it should be modified somehow to getUrl instead?
    cheers,
    Piotr

  55. Piotr says:

    Hi, could anybody please tell me how can I use getUrl function to redirect the page to different url after intro stops playing? The case is still the same – as in the above code – *flv video is not nested in *fla file, but externaly in the same directory. I need exact code :)
    cheers

  56. Piotr says:

    Hi,
    Thanks for that code Dominic, it is what I was searching for one week. Does anybody know how to redirect the page after video stops playing ones – using getUrl command instead of looping? I need exact code in case when *flv video is located externaly, not embeded in *fla file like in the original source code. I am new to flash, so I can’t modify it on my own :(
    cheers

  57. Alex says:

    Great tutorial. How did you know two years ago that I’d be looking for this very solution ;-) Also props for taking the time to explain your code. Even for an Actionscript numpty like myself it makes more sense than some of the other ‘solutions’ I’d found en route to this.

  58. Hazel says:

    Okay, i know this will seem like a stupid question, but i really can’t figure it out -

    My videos preload (or at least they seem to preload) with the buffer (before the first frame of the swf). So that part is great! But i want to play the preloaded videos in other frames (i.e. frames 3, 6, 9 and 12) that also have flvPlaybacks on them already. How do i put the “address” of the preloaded video in the contentPath?

    What i do right now is that on the contentPath of the flvPlayback, i put again the http address of the video – but this instead seems to make the video load AGAIN instead of relying the preloaded vid already. Help please?

    Thank you very much!

  59. Victor says:

    I am unable to watch the demo nor download the source file.

    Please help, I am trying to learn how to load 3 different FLV files which is located in the same directory with an interval of 3 minutes each.

  60. eitan says:

    hi tnx for the tetorial

    i cant find the source codes

  61. mido says:

    hi,,
    plz why the code dont work ?
    just the audio run , video hide

  62. Carl says:

    Hi,

    I’ve been researching flash video and have stumbled across your website but don’t seem to be able to open the demo or download the source files.

    I have Flash Player 10 and have tried using Safari and Firefox without much joy.

    Is the source file still available?

    Cheers

  63. zolo says:

    could u pls reupload the demo and the source code pls pls pls

  64. Rahul clt says:

    i cant find the source codes

  65. Borsi says:

    This solution will make up for the source being removed (for legal reasons I believe).
    For all those having the issue of “not seeing the video” here is the solution:

    1) Go to your Library.
    2) Right-click in the empty area and choose New Video.
    3) For your Options, I guess you can call the symbol anything, but you want to set the type to Video (ActionScript-controlled) then click OK.
    4) Move that Library Object to your stage and give it the appropriate Instance name.

    This will solve the issue of not being able to “see” the video.

    Thank you kindly.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>