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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Applying actions to movieclip frames not yet displayed

Status
Not open for further replies.

digitalpencil

Programmer
Apr 8, 2001
165
GB
Hi,
I've been developing a project that displays FLVs through a video object using the netstream/netconnection method. New FLVs are loaded into the display via buttons in a side-nav MC which, trigger a new netstream path.
In order that I didn't have to apply individual code to each of these buttons, I instead wrote the following actionscript that looks at the instance name of the button that was onReleased, and takes the number on the end of the instance name and uses it as the path to the FLV..


//------- 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);

stream_ns.setBufferTime(15);


stream_ns.onStatus = function(info) {
if(info.code == "NetStream.Buffer.Full") {
bufferClip._visible = false;
}

if(info.code == "NetStream.Buffer.Empty") {
bufferClip._visible = true;
}

if(info.code == "NetStream.Play.Stop") {
ns.seek(0);
}
}

my_video.attachVideo(stream_ns);
stream_ns.play("

//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for(i=1;i<80;i++){
theButton=_root.scrollerMC.thumbscroll["vid"+i];
//this variable stores what number button it is
theButton.thisNum=i;

theButton.onRelease = function() {
//set stream
stream_ns.play("}


controllerMC.rewindBTN.onRelease = function() {
stream_ns.seek(0);
}
}


As i've labelled all my FLVs 1.flv 2.flv etc and the buttons that call them as vid1 vid2 etc, this code is working. However, as my side-nav containing these buttons is broken into three frames, which switch as the user changes a selection in my combo-box; the code (written in my root timeline) is only being applied to the first and currently displaying frame of my side-menu.

Therefore, my question is this.. How can I apply that same code to the second and third frames of the movieclip containing my buttons?

I have uploaded my SWF/FLA to my server for your reference, the urls to each are as follows:
and

Currently there are only associated FLVs uploaded for Le Mans Start and Le Mans End sections although I will be uploading for the cycling section throughout the day.

Any advice you can provide is greatly appreciated,

Thanks,
DigiPencil
 
> How can I apply that same code to the second and third frames of the movieclip containing my buttons?

I don't think you can, but you can re-run the code when your navigation changes. Just place your button code in a function and call it when your navigation changes.

Or do everything in one frame.

Kenneth Kawamoto
 
Can't really do it in one frame so am opting for the function method instead.. so, forgiving my ineptness, how exactly do i do that? as when i wrap it in 'function(buttoncode){}', it just stops working.. doesn't fire any errors in the output window, but doesn't do anything all the same. Equally, how and where do I then call that function (should i be actually able to declare it as one)? in the movieclip's timeline under that frame? or attached to the combo-box code which advances the nav?

Apologies if these are the daftest questions you've received.. today, ad thanks for the advice.
 
What I meant was:
[tt]
...
applyButtonCode()
//
function applyButtonCode(){
//------- DYNAMIC FLV/BUTTON CODE --------------------
//use a for loop to reduce repetition of the code
for (i=1; i<80; i++) {
theButton = _root.scrollerMC.thumbscroll["vid"+i];
//this variable stores what number button it is
theButton.thisNum = i;
theButton.onRelease = function() {
//set stream
stream_ns.play(" };
}
}
...
[/tt]

Then you call this applyButtonCode() when you change the side panel.

Kenneth Kawamoto
 
Thanks Kenneth, big help.
It's stupid things like calling functions I still don't know, now it all makes sense and I think using the same mehtod, I can now fix my buffer code too.

Thanks again!
Digi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top