0

我有一组可以播放的五个可能的视频,称为视频,以及一组称为 activeVideos 的活动视频。当一个视频播放完毕时,我需要获取它的索引,在 activeVideos 数组中找到它的位置,然后获取数组中的下一个值。如果数组中没有更多值,我需要获取第一个值。所以本质上:

activeVideos = [0,1,3]
videos = [video1, video2, video3];

function nextVideo(e:Event){
    var curIndex = videos.indexOf(currentVideo);
    var next = activeVideos.find(curIndex).nextValue // pseudo-code - need to locate the position of the current video within the active array, select the next element, and call show video.
    showVideo(videos[next]);
}

我该怎么做呢?

4

3 回答 3

1
activeVideos = [0,1,3]
videos = [video1, video2, null, video3];

function nextVideo(e:Event){
    var curIndex = videos.indexOf(currentVideo);
    var next = activeVideos[curIndex+1] || activeVideos[0];
    showVideo(videos[next]);
}
于 2012-08-17T16:29:46.857 回答
0

也许你可以在家里试试这个,我必须承认,自从 html5、css3 + js 炒作出现以来,我的 flash 可能有点生疏了 :)

nextIndex = -1;
nextIndex = ( (curIndex+1 == videos.length) ? 0 : curIndex+1 );
if (nextIndex > -1){
  var next = activeVideos[nextIndex];
  // ... do your stuff 
}
于 2012-08-17T16:37:24.770 回答
0
function nextVideo(e:Event){
    var curIndex = videos.indexOf(currentVideo) + 1;
    var nextVideo = curIndex >= videos.length ? videos[0] : videos[curIndex];
    showVideo(nextVideo);
}
于 2012-08-17T16:38:48.617 回答