Announcement

Collapse
No announcement yet.

AS2 to AS3 mouse cursor problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    AS2 to AS3 mouse cursor problem

    I followed the great tutorial on UDN for setting up a scaleform mouse cursor.

    Works great, but now I'm trying to create a UI using AS3 and the small chunk of mouse-related AS no longer compiles (taken straight from the UDN tutorial):

    Code:
    import flash.external.ExternalInterface;
    
    Mouse.hide();
    
    var mouseListener:Object = new Object();
    
    mouseListener.onMouseMove = function ()
    {
      mouseCursor_mc._x = _root._xmouse;
      mouseCursor_mc._y = _root._ymouse;
       
      ExternalInterface.call("UpdateMousePosition", _root._xmouse, _root._ymouse);
       
      updateAfterEvent();
    };
    
    Mouse.addListener(mouseListener);
    I've tried to adapt it to AS3 (without success) to this:

    Code:
    import scaleform.gfx.Extensions;
    Extensions.enabled = true;
    
    Mouse.hide();
    var mouseCursor_mc:MovieClip;
    mouseCursor_mc.mouseEnabled = false;
    mouseCursor_mc.tabEnabled = false;
    
    function handleMouseMove( e:MouseEvent ):void 
    {
    	mouseCursor_mc.x = e.stageX;
    	mouseCursor_mc.y = e.stageY;
    	
    	ExternalInterface.call("UpdateMousePosition", mouseCursor_mc.x, mouseCursor_mc.y);
    }
    
    stage.addEventListener( MouseEvent.MOUSE_MOVE, handleMouseMove, false, 0, true );
    It currently doesn't work. What am I missing? I'm guessing that it's just this small bit of code that I need to change if everything was working fine in AS2.

    #2
    Can anyone offer any guidance? Has anyone else successfully used the same UDN tutorial with AS3?

    Comment


      #3
      I managed to get it to work. Turns out I hadn't names my instance in flash correctly.

      I also didn't need this:
      Code:
      ExternalInterface.call("UpdateMousePosition", mouseCursor_mc.x, mouseCursor_mc.y);
      I also didn't need half of the mouse handling code from the tutorial. I'm not sure why so much of it is now not needed. Is AS3 that much more efficient?

      Anyway, all good now

      Comment

      Working...
      X