A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: mouseover events

  1. #1
    Junior Member
    Join Date
    Sep 2003
    Fairfax, VA

    mouseover events

    How do you indicate that multiple mouseover events have to be true before something happens?

    For example:

    on (rollOver, keyPress"<Space>") {

    the above code will play if I roll over the button with my mouse, OR if I press the space bar. Is there a way to specify that I must first be mousing over the button and THEN press the space bar, for the play action to take place?

  2. #2
    Senior Member catbert303's Avatar
    Join Date
    Aug 2001
    First give your button an instance name (in the code below the instance name is assumed to be btn) then in the frame that contains the button add the following code,


    // set a property on the button to indicate when the mouse is over it
    btn.isOver = false;
    // when the mouse rolls over the button set it to true
    btn.onRollOver = function() {
    this.isOver = true;
    // and when the mouse moves away from the button reset it to false
    btn.onRollOut = btn.onReleaseOutside=function () {
    this.isOver = false;
    // when a key is pressed, check that it was the space bar and that also the isOver property is true
    btn.onKeyDown = function() {
    if (Key.getCode() == Key.SPACE) {
    if (this.isOver) {
    // allow the button to listen for key events

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Click Here to Expand Forum to Full Width

HTML5 Development Center