Skip to main content
Participating Frequently
November 25, 2016
Question

MOUSE OVER, ANIMATE

  • November 25, 2016
  • 2 replies
  • 598 views

Hi guys,

I am a student and I am trying to show a movie clip when the mouse reaches my invisible button (on my second frame).

Well, it's not working at all.

And also, every time I put an EventListener, my button on the first frame stop working.

// FRAME 2:

this.stop();

var KEYCODE_LEF = 37;

var KEYCODE_RIGH = 39;

this.whisky1.visible = false;

this.b1.addEventListener("mouseover",onOver.bind(this));

this.b1.addEventListener("mouseout",onOut.bind(this));

function onOver(){

    this.whisky1.visible = true;

    this.b1.removeAllEventListeners();

}

function onOut(){

    this.whisky1.visible = false;

    this.b1.removeAllEventListeners();

}

document.onkeydown = handleKeyDown.bind(this);

function handleKeyDown(e) {

   

    if (!e) {

        var e = window.event;

    }

    switch (e.keyCode) {

        case KEYCODE_LEF:

            console.log("left");

            this.bagsyMalone1.x -= 25;

           

            if (this.bagsyMalone1.x <= 60){

                this.gotoAndStop(2);

               

            }

            return false;

        case KEYCODE_RIGH:

            console.log("right");

            this.bagsyMalone1.x += 25;

       

            if (this.bagsyMalone1.x >= 450){

                this.gotoAndStop(3);

            }

            return false;

    }

}

// FRAME I:

this.stop();

this.justPlay1.addEventListener("click", gotoNextFrameAndStop.bind(this));

var KEYCODE_LEFT = 37;

var KEYCODE_RIGHT = 39;

document.onkeydown = handleKeyDown.bind(this);

function handleKeyDown(e) {

   

    if (!e) {

        var e = window.event;

    }

    switch (e.keyCode) {

        case KEYCODE_LEFT:

            console.log("left");

            if (this.bagsyMalone1.x >= 60){

                this.bagsyMalone1.x -= 10;

                return false;   

            }

        case KEYCODE_RIGHT:

            console.log("right");

            if (this.bagsyMalone1.x <= 450){

                this.bagsyMalone1.x += 10;

                return false;

            }

    }

}

function gotoNextFrameAndStop()

{

    this.justPlay1.removeAllEventListeners();

    this.gotoAndStop(1);

}

    This topic has been closed for replies.

    2 replies

    Colin Holgate
    Inspiring
    November 25, 2016

    The buttons don't yet exist at the time you're setting the listeners. You could put your code into the second frame the button exists, then the script should be able to find it ok.

    You didn't mention it, but is your invisible button done by having an alpha of zero? That isn't allowed in createjs, either set the alpha to 1, or make it be a regular button, where the idle, over, and down state frames are empty, and the hit frame (the fourth one in the button) would be a rectangle big enough to cover the intended target area.

    Participating Frequently
    November 25, 2016

    I was writing to say, in a polite way, that "naaah, the button was created"!

    But I've check and yes, you are right!

    THANK YOU!!!

    John T Smith
    Community Expert
    Community Expert
    November 25, 2016

    The Forum Lounge is not for technical help, please provide the name of the program you are using so your message may be moved to the correct program forum

    Participating Frequently
    November 25, 2016

    I am sorry.

    The software is animate

    [Moved from non-technical Forum Lounge to specific Program forum... Mod]

    [Here is the list of all Adobe forums... https://forums.adobe.com/welcome]