How to load local FLV file into a movieclip?

How to load local FLV file into a movieclip? I've found the next code but don't know what to do with it.
---------------------><8-------------------------
// CREATE VIDEO CONNECTION TO LOCAL MACHINE
// Set the name of the movie to be played
 fileName = "Intro.flv";
// Create a NetConnection object:
 var netConn:NetConnection = new NetConnection();
// Create a local streaming connection:
 netConn.connect(null);
// Create a NetStream object
 var netStream:NetStream = new NetStream(netConn);
// Define an onStatus() function:
 netStream.onStatus = function(infoObject) {
  status.text += "Status (NetStream)" + newline;
  status.text += "Level: " + infoObject.level + newline;
  status.text += "Code: " + infoObject.code + newline;
  // Turn on the mouse listener if the movie clip has ended.
  // This is how we are restarting the movie.
  if(infoObject.code == "NetStream.Buffer.Empty"){
   mouseListener = new Object();
   mouseListener.onMouseMove = function(){
    trace('play again');
    // TURN OFF THE MOUSE LISTENER
    Mouse.removeListener(mouseListener);
    // Clear status window
    status.text = "";
    // Replay the video
    playExternalVideo(fileName);
   }; Mouse.addListener(mouseListener);
  }
 };
 function playExternalVideo(fn){
 // Attach the NetStream video feed to the Video object:
  this.my_video.attachVideo(netStream);
  // Set the buffer time (seconds):
  netStream.setBufferTime(5);
  // Begin playing the FLV file: on frame 3 not here.
  netStream.play("media/video/"+fn);
 }
 playExternalVideo(fileName);
---------------------><8-------------------------

I've tried to place it into the movieclip's onLoad() event but with no luck.
Could anybody give me a working FLA or at least actionscript code with accurate instructions what and how to do?

Thanks in advance.
LVL 3
abb1Asked:
Who is Participating?
 
SandyCookeCommented:
If anyone knows how to script steps 1-3 I would be very interested, but this should help you in the short term:

1) Choose 'New Video' from the Library pane (call it whatever you like)
2) Drag the object from the library to the stage
3) Name the instance (in this example) 'MyVideo'
4) Add this code to the first frame:

myUrl = "montage.flv"; // change this to the path to your FLV file or you won't see owt
//
var myNetConnection:NetConnection = new NetConnection();
myNetConnection.connect(null);
//
var netStream:NetStream = new NetStream(myNetConnection);
//
myVideo.attachVideo(netStream);
netStream.play(myUrl);

This is everything I have learned so far about FLV playback :)

Sandy
0
 
abb1Author Commented:
I'm really puzzled...

I've just found the same answer in the EE through Google search but EE itself requires a bucks to use EE search engine!
What's a hell!

I understand I must (formally speaking) give these points to you but could you be satisfied if I simply explain what Flash does in fact when you perform the actions 1..3? I've just checked it and the code is pretty short and clear! I would say, it cannot be shorter!
0
 
SandyCookeCommented:
Hi abb1

I've got a better idea: You give me the points for this question and then you go and tell me how to script a New Video object in my question thread:

http://www.experts-exchange.com/Web/WebDevSoftware/Flash/Q_20930371.html

This way we both answer a question!

Sandy
0
 
abb1Author Commented:
It is an iteresting idea to earn expert points for each other :)))

Now I have the next issue: how to synchronize the video playback with other clips (slideshows, etc.). Unfortunately MM doesn't let us to stream slides (like RealMedia does it). Now I have just the only idea - to check NetStream.time and load slides into the slide window (a movieclip) if the time has come.

Also I can't find how to get a total duration of the video currently active. Therefore I don't see a native solution of how to create slider for video navigation. The only idea here is to get the total length information from outside of video (from XML or so).

If you have another and better ideas of how to do that then we could continue our discussin in the another thread.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.