digitalpencil
Programmer
Hi,
I'm currently launching FLVs into a video component using netconnection and netstream. To change the current video, I'm using buttons that update the netsream url via 'ns.play("url")', my question is this: can I pass a variable to the URL parameter of 'ns.play'?
Basically what I'm attempting to do is to specify the URL for each of my FLVs via the instance name of the buttons calling them, rather than attaching code to each button as there will eventually be loads of them.
i.e. say I have three buttons, instance named 'vid1, vid2 and vid3' respectively; and I have 3 videos named 1.flv, 2.flv, 3.flv
I would like to make flash pass the number on the end of the instance name of each button to the URL parameter of ns.play in order that I don't have to attach individual code to loads of buttons.
I have been attempting to use the following code:
//------- SETUP NETSTREAM/CONTROLLER FUNCTIONS/LOADING BAR/SCRUB/TXT -----------
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
display.attachVideo(stream_ns);
stream_ns.play("
//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for(i=1;i<6;i++){
theButton=_root.btnmenu["vid"+i];
//this variable stores what number button it is
theButton.thisNum=i;
theButton.onEnterFrame=function() {
//on release
_root.btnmenu["vid"+this.thisNum].onRelease = function() {
//set stream
stream_ns.play(["]);
}
}
}
This is, however, not passing the variable to the URL parameter of .play
Any ideas how this can be achieved or even a better way around it?
For your reference I have uploaded both a test SWF and FLA to the following:
Any tips/advice are much appreciated,
Thanks,
DigiPencil
I'm currently launching FLVs into a video component using netconnection and netstream. To change the current video, I'm using buttons that update the netsream url via 'ns.play("url")', my question is this: can I pass a variable to the URL parameter of 'ns.play'?
Basically what I'm attempting to do is to specify the URL for each of my FLVs via the instance name of the buttons calling them, rather than attaching code to each button as there will eventually be loads of them.
i.e. say I have three buttons, instance named 'vid1, vid2 and vid3' respectively; and I have 3 videos named 1.flv, 2.flv, 3.flv
I would like to make flash pass the number on the end of the instance name of each button to the URL parameter of ns.play in order that I don't have to attach individual code to loads of buttons.
I have been attempting to use the following code:
//------- SETUP NETSTREAM/CONTROLLER FUNCTIONS/LOADING BAR/SCRUB/TXT -----------
var connection_nc:NetConnection = new NetConnection();
connection_nc.connect(null);
var stream_ns:NetStream = new NetStream(connection_nc);
display.attachVideo(stream_ns);
stream_ns.play("
//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for(i=1;i<6;i++){
theButton=_root.btnmenu["vid"+i];
//this variable stores what number button it is
theButton.thisNum=i;
theButton.onEnterFrame=function() {
//on release
_root.btnmenu["vid"+this.thisNum].onRelease = function() {
//set stream
stream_ns.play(["]);
}
}
}
This is, however, not passing the variable to the URL parameter of .play
Any ideas how this can be achieved or even a better way around it?
For your reference I have uploaded both a test SWF and FLA to the following:
Any tips/advice are much appreciated,
Thanks,
DigiPencil