mardi 22 novembre 2016

Custom Mouse Cursor dropping duplicate symbols after its been removed

first of all, I'm a total noob to as3 and coding in general, I barely operate outside of code snippets.

I'm working on a project, and part of which is a scene where you get a custom mouse cursor upon entering the scene, and when you leave the scene, the custom mouse cursor is removed. The code I'm using to start the custom cursor is:

stage.addChild(crsTemple);
crsTemple.mouseEnabled = false;
crsTemple.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor);

function fl_CustomMouseCursor(event:Event)
{
crsTemple.x = stage.mouseX;
crsTemple.y = stage.mouseY;
}
Mouse.hide();

with crsTemple being the instance name for the custom cursor. Then, when a new scene is entered (via rolling over an object), i have the following code in the new scene:

stage.addChild(crsTemple);
crsTemple.mouseEnabled = false;
crsTemple.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_4);

function fl_CustomMouseCursor_4(event:Event)
{
    crsTemple.x = stage.mouseX;
    crsTemple.y = stage.mouseY;
}
Mouse.hide();

crsTemple.removeEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_4);
stage.removeChild(crsTemple);
Mouse.show();

Unfortunately, whenever I go into the second scene, I get the regular mouse again, but it drops the crsTemple wherever the mouse was when the scene change happened, and it stays there for the rest of the time the file is running.

Any help is greatly appreciated, much thanks in advance for helping a noob like me!

Aucun commentaire:

Enregistrer un commentaire