Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flash AS3视频鼠标事件单击不工作_Flash_Actionscript 3_Events_Click_Mouseevent - Fatal编程技术网

Flash AS3视频鼠标事件单击不工作

Flash AS3视频鼠标事件单击不工作,flash,actionscript-3,events,click,mouseevent,Flash,Actionscript 3,Events,Click,Mouseevent,我创建了一个简单的视频,并尝试将鼠标点击事件附加到视频上,但该事件没有触发。这是我的密码: var connection:NetConnection; var stream:NetStream; var video:Video; connection = new NetConnection(); connection.connect(null); stream = new NetStream(connection); stream.client = this; video = new Vi

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

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)

ymutlu是对的。您需要一个从InteractiveObject继承的类。然而,据我所知,没有必要使用电影唇。更简单的DisplayObjectContainer(如Sprite)可能更合适、更轻。