devmonster
devmonster

Reputation: 1739

recognize mouse click over a flash element

This is a really though one.

I have wrtitten this javascript to connect actions in javascripts and actions in a flash application in my site. The flash app is a bar that displays reltime indices. But it has 4 rows . The user can choose which row to display by pressing the up or down arrow. I am trying to recognize if the user click one of those buttons by recognizing the x and y with

e.pageX and e.pageY

This should works (and it does!) becuase the flash is always on the bottom (fixed position) The thing is that it works in FF but not in chrome or IE.

The code is

$('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
                      .............
                   }
        }

EDIT:

Upvotes: 1

Views: 383

Answers (1)

devmonster
devmonster

Reputation: 1739

Thanks to carnio I changed my approach by sending it through flash external interface. I used

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

and this on the press up and down events

//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);

and it works.

Upvotes: 2

Related Questions