0

When you create a Button Symbol in Animate, it has the Up, Over, Down states. Is there a way to trigger that button Over state from a function?

something like:

button.onRollOver();

Thanks

Retropunk
  • 19
  • 1
  • 5

1 Answers1

0

The Stage handles mouse interaction, and determines what is interacted with. Once it has figured that out, it dispatches an event from that object (source):

var evt = new createjs.MouseEvent(type, bubbles, false, o.x, o.y, nativeEvent, pointerId, pointerId === this._primaryPointerID || pointerId === -1, o.rawX, o.rawY, relatedTarget);
target.dispatchEvent(evt);

You should be able to replicate this fairly simply:

var evt = new createjs.MouseEvent("rollover", false, x, y, null, 0, true, x, y, null);
myBtn.dispatchEvent(evt);

I am not sure exactly what this accomplishes though, since you could just fire the listener(s) that would otherwise get called yourself.

Note also that there is a difference between "mouseover" and "rollover" events. Cheers,

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Thanks for this. I was looking at it the wrong way. DispatchEvent makes total sense. Thanks for the help! – Retropunk Mar 21 '16 at 13:52