From right click problem TO internal setup script (-:

i was using the following code to detect right click (right mouse down) :

// mouse down function
**[color=royalblue]_global.[/color]**checkdown = [color=royalblue]**ASnative**[/color](800,2);
[color=red]// check the right mouse down ( can check other mouse buttons as well)
[/color]checkMouse = [color=seagreen]**function**[/color](){
	 [color=red]// left = checkDown(1)
	 // middle = checkDown(4)
	 // right = checkDown(2)[/color]
		right = checkDown(2)
		**[color=seagreen]if[/color]**(right){
			 [color=red]// do stuff here[/color] 
			 **[color=royalblue]trace[/color]**([color=magenta]"right click detected ! ..."[/color])
	 }
}
[color=red]// update on frame enter
[/color][color=royalblue]**_root.onEnterFrame**[/color] = checkMouse;

but i dun like to use “onEnterFrame” here which can cause
performance issues. If this isnt reasonable for u : i dun like it
to check the statement all the time. not good practice…
I want to have an event handler like “onRightDown”.
we can have it but i dun want “onEnterFrame”
so i tried this one :

 **[color=royalblue]_global[/color]**.checkdown = [color=royalblue]**ASnative**[/color](800,2); 
[color=seagreen]**var**[/color] skin = {}
checkMouse = **[color=seagreen]function[/color]**(){
right = checkDown(2)
[color=seagreen][color=#000000]	 [/color]**if**[/color](right){
[color=royalblue][color=#000000]			 [/color]**trace**[color=#000000]([/color][/color][color=magenta]"right click detected ! ..."[/color][color=#000000])[/color]
	 }
}
**[color=royalblue]Mouse.addListener[/color]**(skin)
skin.**[color=royalblue]onMouseDown[/color]** = checkMouse

but it seems, the name “onMouseDown” is fake coz it just works for the left mouse button. so …the onMouseDown event handler doesnt invoke the “checkMouse” function. Later i found out that ASnative(800,2) is “Key.isDown” method. the following works :

 checkRight = [color=seagreen]**function**[/color](){ 
[color=seagreen][color=#000000]	 [/color]**if**[/color](**[color=royalblue]Key.isDown[/color]**(4)){
[color=royalblue][color=#000000]			 [/color]**trace**[color=#000000]([/color][color=magenta]"right click detected ! ..."[/color][color=#000000])[/color][/color]
	 }
}
**[color=royalblue]_root.onEnterFrame[/color]** = checkRight

so we think that we can use the onKeyDown event handler for
our purpose but we again cant do it. the following code duznt work :

 **[color=seagreen]var[/color]** skin = {} 
checkRight = function(){
[color=seagreen][color=#000000]	 [/color]**if**[/color](Key.isDown(4)){
[color=#4169e1][color=#000000]			 [/color]**trace**[/color][color=#000000]([/color][color=magenta]"right click detected ! ..."[/color][color=#000000])[/color]
	 }
}
**[color=royalblue]Key.addListener[/color]**(skin)
skin.[color=royalblue]**onKeyDown**[/color] = checkRight

before asking my main question, we have these stuff :

  • ASnative(800,2) is the “Key.isDown” method or the same function that duz the same thing
  • So it s acceptable that “onMouseDown” duznt work … maybe internally it s passed to the Mouse object when setting up classes, objects, etc…
  • this method ( ASnative(800,2) ) is a plain function that infact duznt belong
    to the Key object internally ( which probably is setup with internal script to belong to )
    Because, otherwise “onKeyDown” would work with the Key object. And i dun know, how to avoid this for the Key object to work …

i m sleepy n i m kinda confused

  • does anyone have an idea or know how this can be set up ?
    i have used AsBroadcaster in some stuff i ve done. So i know about events / event handling / broadcasting …
  • i want to know how events r broadcasted internally ? like :
    if we left click the mouse . how does it happen ?
 [color=red]// when the event occurs :[/color] 
[color=red]/* 1 */[/color] [color=royalblue]**Mouse.broadcastMessage**[/color]([color=magenta]"onMouseDown"[/color])
[color=red]// n this executes the "onMouseDown" function on listeners ?[/color]
[color=red]//or 2 ASnative correspondant function (named "onMouseDown") is fired directly ?[/color]

if anyone knows stuff about these, i d really like to know ( the stuff mostly on the compiling level)

cheers…