Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

netstream.play URL parameter

Status
Not open for further replies.

digitalpencil

Programmer
Apr 8, 2001
165
0
0
GB
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 haven't looked at your FLA but looking at your post I think the script should be:

[tt]//------- 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.onRelease = function() {
//set stream
stream_ns.play(" };
}
[/tt]

Kenneth Kawamoto
 
You're right, thanks! I worked it out this morning myself.. Don't know why I included an onenterframe, wasn't neede, neither we're the square brackets.

Thanks again,
Digi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top