Если контекстное меню было открыто над областью с видео, то у его пунктов не вызывается событие ContextMenuEvent.MENU_ITEM_SELECT.
Код:
package
{
import flash.display.Sprite;
import flash.events.ContextMenuEvent;
import flash.events.NetStatusEvent;
import flash.media.Video;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
public class Test extends Sprite
{
private var _connection:NetConnection;
private var _video:Video;
private var _stream:NetStream;
//путь к flv-файлу.
private var _videoURL:String = "flvfile_url";
public function Test()
{
super();
this.graphics.beginFill(0x00ff00);
this.graphics.drawRect(0, 0, 600, 600);
this.setupContextMenu();
this.setupVideo();
}
private function setupContextMenu():void
{
var item:ContextMenuItem = new ContextMenuItem("test context menu");
this.contextMenu = new ContextMenu();
this.contextMenu.hideBuiltInItems();
this.contextMenu.customItems = [item];
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, this.menuItemSelectHandler);
}
private function setupVideo():void
{
this._connection = new NetConnection();
this._connection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
this._connection.connect(null);
}
private function connectStream():void
{
this._stream = new NetStream(this._connection);
this._stream.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
this._video = new Video();
this._video.attachNetStream(this._stream);
this._stream.play(this._videoURL);
this.addChild(this._video);
}
private function netStatusHandler(event:NetStatusEvent):void
{
switch (event.info.code)
{
case "NetConnection.Connect.Success":
connectStream();
break;
}
}
private function menuItemSelectHandler(event:ContextMenuEvent):void
{
trace(event);
}
}
}
Вопрос: так было всегда и я просто этого не замечал?