0

当单击事件针对父元素时,检查鼠标是否在子元素内单击的代码是什么。仅当单击位于子元素内时,我才需要区分以执行某些任务。flex中发生了什么样的传播?我对此有点陌生。

我有一个带有视频显示和视频控制栏的视频播放器。我为占据全屏的视频播放器注册了点击事件。单击时,控制栏应切换(如编程),但单击控制栏中的任何元素时,整个栏都会消失。

<!-- Player Container -->
<s:BorderContainer width="100%" height="100%"
           backgroundAlpha="0"
           borderVisible="false">

  <s:VideoPlayer id="vid_player"
          width="100%" height="100%"
          verticalCenter="0"
          horizontalCenter="0"
          skinClass="Skins.VideoPlayerSkin"
          maintainProjectionCenter="true"
          mouseDown="hideControls(event)"
          autoPlay="true" source="{current_video.getSource()}"/>            
</s:BorderContainer><!-- Player Container -->

public function hideControls(event:Event):void {
  hidePlaylist();
  toggleElem(header);
  toggleElem(sec_drop_container);
  toggleVideoPlayer();
}

public function toggleVideoPlayer() {
    var controls:Object = vid_player.videoDisplay.parent.getChildAt(1);
    if(controls.visible)
        controls.visible=false;
    else
        controls.visible  = true;
}
4

1 回答 1

2

可能最简单的方法是:

private function mouseHandler(event:MouseEvent/*was e:MouseEvent*/):void {
    whateverObject.hitTestPoint(event.stageX, event.stageY, false); // use shape flag is 3rd argument
}
于 2013-01-17T18:19:46.530 回答