Copy link to clipboard
Copied
Hi guys, so I have this bit of code :
import flash.events.MouseEvent;
import flash.events.Event;
stop();
addEventListener(Event.ENTER_FRAME, GetMouse);
function GetMouse(event:Event)
{
if(mouseX>365 && mouseX<613 && mouseY <170 && mouseY >120)
{
Mouse.cursor="button";
addEventListener(MouseEvent.MOUSE_DOWN, goToLevel);
function goToLevel(event:MouseEvent):void
{
gotoAndStop(1, "Lv1");
}
}
else if(mouseX>365 && mouseX<613 && mouseY <234 && mouseY >185)
{
Mouse.cursor="button";
addEventListener(MouseEvent.MOUSE_DOWN, goToLevelSelect);
function goToLevelSelect(event:MouseEvent):void
{
gotoAndStop(2, "LvSelect");
}
}
else
{
Mouse.cursor="auto";
}
}
And it basically makes my first scene have 2 clickable buttons that lead me to a 2nd and 3rd scene. The problem is that once I am on scene 2 or 3, the cursor stays like if it was on a button when i put it over the zone i defined in the other scene, I thought code would not affect my other scenes that's why I did that. Is there any way I can make my cursor go back to normal in the other scenes?
do you have any problem in scene 2 after that code executes and you apply no other Mouse.cursor code?
Copy link to clipboard
Copied
assign it to "auto" when in other scenes.
Copy link to clipboard
Copied
Mouse.cursor="auto";
Got this on scene 2 but I still have the button cursor appear when I go to the same locations as scene 1
Copy link to clipboard
Copied
do you have any problem in scene 2 after that code executes and you apply no other Mouse.cursor code?
Copy link to clipboard
Copied
I got the cursor to stay normal afterwards with this code :
import flash.events.MouseEvent;
import flash.events.Event;
stop();
addEventListener(Event.ENTER_FRAME, GetMouse);
function GetMouse(event:Event)
{
if(mouseX>365 && mouseX<613 && mouseY <170 && mouseY >120)
{
addEventListener (MouseEvent.ROLL_OVER,sqrOver);
addEventListener(MouseEvent.MOUSE_DOWN, goToLevel);
function goToLevel(event:MouseEvent):void
{
gotoAndStop(1, "Lv1");
}
}
else if(mouseX>365 && mouseX<613 && mouseY <234 && mouseY >185)
{
addEventListener (MouseEvent.ROLL_OVER,sqrOver);
addEventListener(MouseEvent.MOUSE_DOWN, goToLevelSelect);
function goToLevelSelect(event:MouseEvent):void
{
gotoAndStop(2, "LvSelect");
}
}
else
{
Mouse.cursor="auto";
}
function sqrOver(event:MouseEvent):void
{
Mouse.cursor="button";
}
}
But there is still a problem because when I click on the spots that were clickable on scene 1, they do the same in scene 2 and 3, why is that? Isn't there a way to separate code so that it doesn't interfere with other classes?
Copy link to clipboard
Copied
are you forgetting to terminate your enterframe loop? that would cause the problems you describe.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now