Skip to main content
September 26, 2008
Question

Movie Looping Problem with NetConnection Script

  • September 26, 2008
  • 1 reply
  • 219 views
I had a friend help me write the following script (AS 2.0 script listed below) to play the first video then play a second shorter one that loops.

He is not available right now but told me it could be done in one keyframe!

Thus, I imported both FLV files via "progressive download" and made sure the video was ActionScript controlled. I made sure the first video instance was named "v1" as the script states. I did not give an instance name to the second video though.

Using these conditions only the first video runs and never gets to the second video. I've playe around putting the second video in another keyframe or layer but to no avail!

Any help correcting my mis-steps is greatly appreciated.

var videoA:Array = ["openingVideo.flv","starfieldVideo.flv"];
var tl:MovieClip =this;

var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
v1.attachVideo(ns);
ns.play(videoA[0]);

ns.onMetaData = function(infoObject:Object) {
durationVar = infoObject["duration"];

if(!tl.onEnterFrame){
tl.onEnterFrame = playProgressF;
}
};


function playProgressF(){
if(ns.time >= durationVar){
ns.play(videoA[1])
}
}
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
September 27, 2008
you should only have one video instance. (and that code looks amazingly familiar. who gave you that code?)