从总共 5 个 flv 中随机播放一个 flv
我需要您关于 Actionscipt3.0 的帮助。说实话我对flash实在是菜鸟。我更像是一名 3D 设计师,所以没有太多 flash ;) 目前我必须创建一个网站,其中一些视频应该自动播放。
当用户打开 URL 并登陆页面时,应播放总共 5 个随机视频。当视频播放完毕后,它应该从总共 5 个视频中选择另一个视频。
举个例子:它应该从 5 个视频中选择一个视频。播放它,然后它应该选择 4 个视频中的 1 个视频,然后它应该选择 3 个视频中的 1 个视频..等等。当所有 5 个都玩完后,它应该重复这个过程。
我希望这里有人可以帮助我......到目前为止我所拥有的是......
var 文件:Array = [ "Sz01Puppet.flv", "Sz02Puppet.flv", "Sz03Puppet.flv", "Sz04Puppet.flv", "Sz05Puppet.flv"];变量 randomFiles:Array = [];
var i:int;对于(i = 0;我 randomFiles.push(files[Math.floor(Math.random() * files.length)]); }
跟踪(随机文件);
但它没有以任何方式工作..
如果有人能帮助我那就太好了
I need your help with Actionscipt3.0. To be honest I am reall noob in flash. I am more a 3D Designer so not a lot of flash ;)
Currently I have to create a website where some videos should be played automatically.
When a User opens the URL and lands on the page, a random video of a total of 5 should be played. When the video is finished, it should chose another video of the total of 5 videos.
So an example: It should chose one video of 5 videos. Play it, then it should chose 1 video of 4 videos, then it should chose 1 video of 3 videos..and so on. And after all 5 are played, it should repeat the process.
I hope someone here can help me with that...What i have sofar is this..
var files:Array = [ "Sz01Puppet.flv", "Sz02Puppet.flv",
"Sz03Puppet.flv", "Sz04Puppet.flv", "Sz05Puppet.flv" ]; var
randomFiles:Array = [];var i:int; for (i=0; i
randomFiles.push(files[Math.floor(Math.random() * files.length)]);
}trace(randomFiles);
But its not working in any way..
Would be great if someone could help me out
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,你就快到了。
下面是 for 循环的编写方式:
不过,您会注意到从数组中删除了项目,因此您将有重复项。
这是一个例子:
Goodluck
Yup, you're nearly there.
Here's how the for loop should've been written:
Still, you're note removing items form the array, so you'll have duplicates.
Here's an an example:
Goodluck
您可以使用 Array.sort() 函数对其进行随机排序。
You could use the Array.sort() function to sort it randomly.
这里是一种方法。
Here is one way to do it.