Is it possible to define a variable inside of function where the actual variable name will change based on what parameters the function is called with? Take a look at this code:
//define the function
function attachVid(nc, ns, curVid, vidFile) {
//I want the nc on the left side of this variable assignment to change to "video1", the name coming from the command calling the funtion
var nc = new NetConnection();
nc.connect(null);
//I want the ns on the left side of this variable assignment to change to "videoStream1", the name coming from the command calling the funtion
var ns = new NetStream(nc);
//The curVid part of the will be replaced with _root.my_mc1 (instance name of an embedded video object sitting on the stage), the name coming from the command calling the function
curVid.attachVideo(ns);
ns.connect();
//the vidFile part of this snippet is changed to "millersgap_med001.flv", the FLV name coming from the function call
ns.play(vidFile);
}
//call the function
attachVid("video1", "videoStream1", _root.my_mc1, "millersgap_med001.flv");
I am trying to make the net Connection and net Stream object unique each time the function is called because I am trying to play like 5 flv’s on stage simultaneously. As far as I know, each video stream needs a unique net Connection and a unique net Stream object. But it doesn’t seem to be working. Does anyone see any problems with my code?