lundi 22 février 2016

Flash AS3 MouseOver not working

I am having trouble getting a MOUSE_OVER event to fire consistently and as intended. I have a custom cursor (movieclip) attached to my mouse and it has 2 frames (1st frame cursor is black and second frame it is white).

Here is code from my cursor script:

    private function onAddedToStage(event:Event):void
    {
        gotoAndStop(1);
        this.mouseChildren = false;
        this.mouseEnabled = false;
    }
    public function rollover():void
    {
        gotoAndStop(2);
        trace("change cursor");
    }

Here is the class for an object that will react when the cursor moves over it:

public class DoorHS01 extends MovieClip
{
    public var cursor:Cursor;
    public function DoorHS01() 
    {
        cursor = new Cursor();

        this.addEventListener(MouseEvent.MOUSE_OVER, rollover);
    }

    public function rollover(e:MouseEvent):void
    {
        cursor.rollover();
        trace("rollover");
    }
}

}

So in the DoorHS01 class the MouseEvent doesn't always fire or it will be really delayed. The cursor.rollever function gets called and it executes in the cursor class (I know from the traces) but the cursor never changes.

What am I missing?

Aucun commentaire:

Enregistrer un commentaire