开发者

AS3 Video MouseEvent Click not working

I created a simple video and I tried attaching a mouse click event to it but the event doesnt fire. Here is my code:

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");                                                
});

What is wrong with it and why wont the mouse event work?


Put video in a movieClip and add the event to 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");                                                
});

Note: The Video class is not a subclass of the InteractiveObject class, so it cannot dispatch mouse events. However, you can call the addEventListener() method on the display object container that contains the Video object. (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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜