gpt4 book ai didi

flash - AS3 Video MouseEvent Click 不起作用

转载 作者:行者123 更新时间:2023-12-02 02:22:00 25 4
gpt4 key购买 nike

我创建了一个简单的视频,并尝试将鼠标单击事件附加到它,但该事件没有触发。这是我的代码:

var connection:NetConnection;
var stream:NetStream;
var video:Video;

connection = new NetConnection();
connection.connect(null);

stream = new NetStream(connection);
stream.client = this;

video = new Video(425, 320);
stage.addChild(video);


video.attachNetStream(stream);

stream.bufferTime = 1;

stream.receiveAudio(true);
stream.receiveVideo(true);

stream.play("freshprince.flv");

video.addEventListener(MouseEvent.CLICK, function() {

trace("Video Clicked");
});

它有什么问题,为什么鼠标事件不起作用?

最佳答案

将视频放入一个movieClip,并将事件添加到movieClip

video = new Video(425, 320);
var mc:MovieClip = new MovieClip();
mc.addChild(video);
stage.addChild(mc);

mc.addEventListener(MouseEvent.CLICK, function() {
trace("Video Clicked");
});

注意:Video 类不是 InteractiveObject 类的子类,因此它不能调度鼠标事件。但是,您可以在包含视频对象的显示对象容器上调用 addEventListener() 方法。(http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Video.html?filter_flash=cs5&filter_flashplayer=10.2&filter_air=2.6)

关于flash - AS3 Video MouseEvent Click 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7707641/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com