动作脚本、flash、ns - 如果条件为真则循环播放 flv
祝大家美好的一天。
如果条件成立,我需要在闪存中循环播放 flv 文件。
所以我尝试添加一个侦听器,但 id 不起作用。代码如下:
textBox.addEventListener(FocusEvent.FOCUS_IN, focusInListener);
var connection:NetConnection = new NetConnection();
var stream:NetStream;
var video:
Video = new Video(200, 200);
var metaObj:Object = new Object();
function onMetaData(data:Object):void {
}
var checkvid=0;
connection.connect(null);
stream = new NetStream(connection);
stream.client = metaObj;
metaObj.onMetaData = onMetaData;
video.attachNetStream(stream);
addChild(video);
stream.play("Mann ft. 50 Cent - Buzzin 2010-(mrsjs).flv");
video.x = 0;
video.y = 40;
textBox.addEventListener(KeyboardEvent.KEY_DOWN,handler);
function handler(event:KeyboardEvent)
{
if(event.charCode == 13) // if the key is ENTER
{
switch (textBox.text)
{
case "1":
stream.play("m1.flv");
checkvid=0;
// Note from Slomojo - You probably wanted a break; here.
case "2":
stream.play("m2.flv");
checkvid=1;
break;
case "3":
stream.play("m3.flv");
checkvid=0;
break;
}
}
}
var listener:Object = new Object();
listener.complete = function():Void {
stream.seek(0);
stream.play();
}
stream.addEventListener("complete", listener);
任何想法都表示赞赏。谢谢。
Good day to all.
I need to loop a flv file in flash if a condition is true.
So I tryed to add a listener but id doesn't work.. Code below:
textBox.addEventListener(FocusEvent.FOCUS_IN, focusInListener);
var connection:NetConnection = new NetConnection();
var stream:NetStream;
var video:
Video = new Video(200, 200);
var metaObj:Object = new Object();
function onMetaData(data:Object):void {
}
var checkvid=0;
connection.connect(null);
stream = new NetStream(connection);
stream.client = metaObj;
metaObj.onMetaData = onMetaData;
video.attachNetStream(stream);
addChild(video);
stream.play("Mann ft. 50 Cent - Buzzin 2010-(mrsjs).flv");
video.x = 0;
video.y = 40;
textBox.addEventListener(KeyboardEvent.KEY_DOWN,handler);
function handler(event:KeyboardEvent)
{
if(event.charCode == 13) // if the key is ENTER
{
switch (textBox.text)
{
case "1":
stream.play("m1.flv");
checkvid=0;
// Note from Slomojo - You probably wanted a break; here.
case "2":
stream.play("m2.flv");
checkvid=1;
break;
case "3":
stream.play("m3.flv");
checkvid=0;
break;
}
}
}
var listener:Object = new Object();
listener.complete = function():Void {
stream.seek(0);
stream.play();
}
stream.addEventListener("complete", listener);
Any idea is appreciated. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
NetStream
不会触发complete
事件,并且您错误地执行了侦听器对象,您对NetStream
使用直接回调函数,请参阅此处:http://livedocs.adobe.com /flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html#event:onPlayStatus
基本上,您监听
onStatus
- 为其分配一个回调...即:您想要的信息位于
infoObject
中。NetStream
doesn't fire acomplete
event, and you're doing the listener object incorrectly, you use a direct callback function for theNetStream
See here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/net/NetStream.html#event:onPlayStatus
Basically, you listen to
onStatus
- assign a callback to it... ie:The information you want is in the
infoObject
.我建议这个解决方案:
所以,你需要实现 repeadMethod,这可以是:
I suggest this solution:
So, you need to implement the repeadMethod, this can be as: