【问题标题】:recognize mouse click over a flash element识别鼠标单击 Flash 元素
【发布时间】:2012-06-20 14:56:13
【问题描述】:

这确实是一个。

我已经编写了这个 javascript 以在我的 site 中连接 javascripts 中的操作和 flash 应用程序中的操作。 Flash 应用程序是一个显示相对时间索引的栏。 但它有 4 行 。用户可以通过按选择显示哪一行 向上或向下箭头。 我试图通过使用

识别 x 和 y 来识别用户是否单击了这些按钮之一
e.pageX and e.pageY

这应该有效(确实有效!)因为闪光灯始终位于底部(固定位置) 问题是它在 FF 中有效,但在 chrome 或 IE 中无效。

代码是

$('body').click(function(e){

    var arrowWidth  = 15;
    var arrowHeight = 12;

    x_left      = $("body").width() * 0.88 - 30;
    x_right     = $("body").width() * 0.88;

    y_down_bottom       = $(window).height() -2//screen.height; //$
    y_down_top      = y_down_bottom - arrowHeight;
    y_up_bottom     = y_down_bottom - arrowHeight-2;
    y_up_top        = y_up_bottom   - arrowHeight-4;


    if (e.pageX > x_left && e.pageX < x_right ){
        if (e.pageY>=y_down_top && e.pageY<=y_down_bottom ){
                    //pressed down
                      .............
                   }
        }

编辑:

【问题讨论】:

  • 最好让Flash影片本身与页面通信,可以吗?我的意思是你能修改和重新编译 Flash 电影吗?
  • 1.你能给出示例代码吗?
  • 2.我不是一个 Flash 编码器,但如果代码足够简单,我可能会管理
  • 我试过了,但它在 IE 中不起作用(我已经编辑了问题)。任何想法为什么?

标签: javascript jquery flash mouseclick-event


【解决方案1】:

感谢 carnio,我通过 Flash 外部接口发送它来改变我的方法。 我用过

import flash.external.*; // for sending up and down arrows events to javascript

还有这个关于上下按下的事件

//update javascript
// The name of a JavaScript function to call 
var callJasFunction:String = "GetBtnTicker";
//parameter 
var msg:int = page;
//  The return value after calling JavaScript 
ExternalInterface.call(callJasFunction, msg);

它有效。

【讨论】:

  • 很高兴看到有人真正费心自己解决问题 - 干得好。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-30
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多