Is it possible to target a mouseEvent
via a dispatchEvent
in AS3 whilst controlling the conditions withing the Method?
I'm able to work out how to target the Method but wondered if it's possible to simulate a click with showing==n
being active at the same time.
With a standard dispatchEvent
it doesn't register the conditions so I hoped there was a way to pre-assign it.
function clickthumb(e:MouseEvent):void{
//determine condition
var n:int=thumbs.indexOf(e.currentTarget);
if(showing==n){
trace("clicked Main target");
} else {
var diff:int=showing-n;
moveArray(-diff);
trace("clicked Side Target");
}
}
target_btn.dispatchEvent(new MouseEvent(MouseEvent.CLICK, clickthumb, false, 0, true));
Any help will be greatly appreciated, thanks for your time.
dispatchEvent
is not used that way, you need to useaddEventListener
for custom functions, otherwise you could usetarget_btn.dispatchEvent(new MouseEvent(MouseEvent.CLICK));
I think you are looking for: