views:

103

answers:

1

I've got a load of videos

var ns1:NetStream = new NetStream(nc);
container1.compMa.theVideo.attachVideo(ns1);
ns1.play("sukh_diesel.flv", 1);

//

var ns2:NetStream = new NetStream(nc);
container2.compMa.theVideo.attachVideo(ns2);
ns2.play("sukh_beneath.flv", 1);

//and 4 more, which I've left out to be concise

I want to pause them with

function pauseVid(){
this.ns1.pause();
  for(i=1;i<7;i++){
  this["ns"+i]pause();
  }
}

the commented out line:

this.ns1.pause()

works, but when I try it in a loop it can't access it?

A: 

Have you tried using eval to access your stream by name?

function pauseVid(){
  var localStream:NetStream;
  for(i=1;i<=7;i++){
      localStream = eval("ns"+i);
      localStream.pause();
  }
}

I would recommend keeping track of your objects with an array of streams for example. This way you would avoid change the upper limit of your for statement.

jdecuyper