Showcase and discover digital art at yex

Follow Design Stacks

Subscribe to our free newsletter to get all our latest tutorials and articles delivered directly to your inbox!

Streaming FLV files in Flash MX 2004

“Streaming” FLV files in Flash MX 2004

If you haven’t yet used NetConnection and NetStream right in Flash MX 2004, why don’t you give it a try. Now you can dynamically load FLV files right in Flash without the FlashCom server.

  1. var connection_nc:NetConnection;
  2. var stream_ns:NetStream;
  3. var clickListener:Object = new Object();
  4. clickListener.click = function() {
  5.     connection_nc = new NetConnection();
  6.     connection_nc.connect(null);
  7.     stream_ns = new NetStream(connection_nc);
  8.     stream_ns.setBufferTime(5);
  9.     movie_video.attachVideo(stream_ns);
  10.     stream_ns.play(“video1.flv”);
  11. };
  12. play_btn.addEventListener(“click”, clickListener);

Note that if you strict type inside the function, this code will not work. So, if you don’t use a function, this code works just fine.

  1. var connection_nc:NetConnection = new NetConnection();
  2. connection_nc.connect(null);
  3. var stream_ns:NetStream = new NetStream(connection_nc);
  4. stream_ns.setBufferTime(5);
  5. movie_video.attachVideo(stream_ns);
  6. stream_ns.play(“video1.flv”);

Comments