Reputation: 353
I am looking for a way to perform mouse functions via code without having to actually touch the mouse. Left clicking and positioning cursor to be specific. What I am trying to do is allow my app to create macros that perform certain functions with a single button press or timed event.
Upvotes: 0
Views: 41
Reputation: 15881
"I am looking for a way to perform mouse functions via code without having to actually touch the mouse.
Left clicking and positioning cursor to be specific."
(1) Simulate left click :
Use xxx :MouseEvent = null
to allow manual running of some function even without a physical mouse click.
function some_mouseHandler ( event:MouseEvent = null ) :void
{
//do relevant stuff...
}
Then you can then access above function by either mouse or via direct function execution.
mc_btn.addEventListener(MouseEvent.CLICK, some_mouseHandler ); //for: using mouse.
some_mouseHandler(); //for: direct, no mouse.
(2) Position cursor :
Have some custom MC or Sprite ready to act as replacement icon. It is this custom icon that your user moves around by mouse, then later your code can also auto-move the same custom "pointer" icon (via tweens?).
Mouse.hide(); //else: Mouse.show();
stage.addEventListener(Event.ENTER_FRAME, user_move_Cursor);
function user_move_Cursor(event:Event)
{
mc_cursor.x = stage.mouseX;
mc_cursor.y = stage.mouseY;
}
Upvotes: 1