【问题标题】:Flash - Only show message on load if user is not already over the movieFlash - 如果用户还没有看完电影,则仅在加载时显示消息
【发布时间】:2011-04-13 08:35:05
【问题描述】:

我有一个 Flash 电影,它在首次加载时向用户显示一条消息。当用户鼠标进入舞台或移动鼠标时,消息消失。但是,如果用户在页面加载时将鼠标悬停在 flash 电影上,我想隐藏该消息。这是可能的还是需要先进行交互?

谢谢

【问题讨论】:

    标签: flash actionscript-3 mouseevent


    【解决方案1】:

    您可以创建一个与舞台具有相同xywidthheight 值的矩形对象。然后创建一个条件(if 语句),在启动应用程序时检查Rectangle 对象是否包含舞台的mouseXmouseY 值。以下是对此的简单测试:

    package 
    {
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.geom.Rectangle;
        import flash.text.TextField;
    
        public class Main extends Sprite 
        {
    
            public function Main():void 
            {
                if (stage) init();
                else addEventListener(Event.ADDED_TO_STAGE, init);
    
            }// end function
    
            private function init(e:Event = null):void 
            {
                removeEventListener(Event.ADDED_TO_STAGE, init);
    
                var textField:TextField = new TextField();
                addChild(textField);
    
                var stageRect:Rectangle = new Rectangle(stage.x, stage.y, stage.stageWidth, stage.stageHeight);
    
                if (stageRect.contains(stage.mouseX, stage.mouseY))
                {
                    textField.text = "mouse is inside stage upon initiation";
    
                }
                else
                {
                    textField.text = "mouse is outside stage upon initiation";
    
                }// end if
    
            }// end function
    
        }// end class
    
    }// end package
    

    【讨论】:

    • 您好,感谢您的回复,但是一旦我将它嵌入到网页中,这似乎不起作用,即使使用上面的示例也是如此。有什么想法吗?
    • 我认为您可能需要先使用 javascript 或 jquery 设置 Flash 的焦点,以确保它在加载时会读取鼠标。
    猜你喜欢
    • 2019-08-20
    • 2011-06-20
    • 1970-01-01
    • 1970-01-01
    • 2011-03-30
    • 1970-01-01
    • 2016-02-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多