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

Custom cursor on roll over

New Here ,
May 29, 2014 May 29, 2014

Hi guys,

I'm trying to get my cursor to change to a custom MovieClip when a certain area is rolled over. My code works but as soon as the rollover is fired the rollout is also fired which creates a loop back and forth the two listeners so the cursor looks like its flickering. I think it may be something to do with the startDrag/stopDrag i have on the custom cursor as i don't get this effect if i remove them. This seems like it should be really straight forward to do but i've tried a few different approaches and keep getting the same effect. What am i missing?

Cheers!

Matt

Code as follows:

var customCursor_mc:CustomCursor = new CustomCursor();


activeArea_mc.addEventListener(MouseEvent.ROLL_OVER, handleEvents);

activeArea_mc.addEventListener(MouseEvent.ROLL_OUT, handleEvents);

activeArea_mc.addEventListener(MouseEvent.CLICK, handleEvents);

function handleEvents(e:MouseEvent):void

{

  switch(e.type)

  {

  case "click":

       trace("clicked");


  break;

  case "rollOver":

       trace("over");

       Mouse.hide();

       customCursor_mc.startDrag(true);

       addChild(customCursor_mc);

  break;

  case "rollOut":

       trace("out");

       Mouse.show();

       customCursor_mc.stopDrag();

       removeChild(customCursor_mc);

  break;

  }

}

TOPICS
ActionScript
443
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

Guide , May 29, 2014 May 29, 2014

Hm, that sounds like the cursor itself is causing the problem. Set it to mouseEnabled = false and mouseChildren =  false

Translate
Guide ,
May 29, 2014 May 29, 2014

Add a transparent Shape (i.e. just draw with the Rectangle or Rectangle primitive tool) over everything inside the thing you're rolling over. ROLL_OUT is being triggered because it's rolling over an internal object.

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
New Here ,
May 29, 2014 May 29, 2014

Hi Amy,

Thanks for the reply, i've just tried your solution but it doesn't seem to make any difference. The clip being rolled over is a movieClip with a rectangle primitive inside, this defines a 'hit' area. if i remove the startdrag the rollOut/Over events fire  as expected. Sorry perhaps i've misunderstood what you meant?

Matt

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
Guide ,
May 29, 2014 May 29, 2014

Hm, that sounds like the cursor itself is causing the problem. Set it to mouseEnabled = false and mouseChildren =  false

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
New Here ,
May 30, 2014 May 30, 2014
LATEST

Ah ha! Thanks Amy that seems to of solved it. Seems strange that was causing the issue though as the cursor clip is just an mc without any mouse event listeners on it at all?!  Probably just a strange issue with Flash maybe!

Many Thanks

Matt

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