Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to make mouse become normal again on an other scene

Guest
Nov 15, 2013 Nov 15, 2013

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?

TOPICS
ActionScript
869
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Nov 15, 2013 Nov 15, 2013

do you have any problem in scene 2 after that code executes and you apply no other Mouse.cursor code?

Translate
Community Expert ,
Nov 15, 2013 Nov 15, 2013

assign it to "auto" when in other scenes.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 15, 2013 Nov 15, 2013

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 15, 2013 Nov 15, 2013

do you have any problem in scene 2 after that code executes and you apply no other Mouse.cursor code?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Nov 16, 2013 Nov 16, 2013

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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 16, 2013 Nov 16, 2013
LATEST

are you forgetting to terminate your enterframe loop?  that would cause the problems you describe.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines