A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: movieclip follow mouse

  1. #1
    Member
    Join Date
    Mar 2009
    Posts
    34

    movieclip follow mouse

    Hi,

    Is there anyway to make a movieclip follow the mouse. I have a menu, as a movieclip and when i roll over the menu i want something to pop up where the mouse is that says 'click & drag to scroll'

    my main menu is called: container_mc
    the movieclip i want to appear i have exported it for actionscript and is called mouseovermenu.

    This is the AS3 i have so far:

    Code:
    container_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
    
    container_mc.buttonMode = true;
    container_mc.useHandCursor = true;
    
    function onRollOverHandler(myEvent:MouseEvent){
    var myPopup:DisplayObject = addChild(new mouseovermenu());
    myPopup.x = mouseX;
    myPopup.y = mouseY;
    }
    At the moment the pop up appears when i roll over but it dosnt follow the mouse. Also, i am getting more than one instance of the rollover movieclip appearing.

    Can anyone help?

    Thanks

    Matt

  2. #2
    Member
    Join Date
    May 2010
    Posts
    67
    PHP Code:
    container_mc.addEventListener(MouseEvent.ROLL_OVERonRollOverHandler);

    container_mc.buttonMode true;
    container_mc.useHandCursor true;

    var 
    myPopup:DisplayObject = new mouseovermenu();
    myPopup.addEventListener(MouseEvent.MOUSE_DOWNpopupMouseDownfalse0true);
    myPopup.addEventListener(MouseEvent.MOUSE_UPpopupMouseUpfalse0true);


    function 
    onRollOverHandler(myEvent:MouseEvent){
    addChild(myPopup);
    myPopup.mouseX;
    myPopup.mouseY;
    }

    function 
    popupMouseDown(e:MouseEvent)
    {
        
    stage.addEventListener(MouseEvent.MOUSE_MOVEpopupMouseMovetrue0true);
        
    stage.addEventListener(MouseEvent.MOUSE_MOVEpopupMouseMovefalse0true);
    }

    function 
    popupMouseUp(e:MouseEvent)
    {
        
    stage.removeEventListener(MouseEvent.MOUSE_MOVEpopupMouseMovetrue);
        
    stage.removeEventListener(MouseEvent.MOUSE_MOVEpopupMouseMovefalse);
    }

    function 
    popupMouseMove(e:MouseEvent)
    {
        var 
    p:Point this.globalToLocal(new Point(e.stageXe.stageY));
        
    myPopup.p.x;
        
    myPopup.p.y;

    Or look up startDrag and stopDrag functions... Depends on what else you want to do with it i guess...

  3. #3
    Designer, Programmer, Musician angelhdz's Avatar
    Join Date
    Mar 2010
    Posts
    971
    try fixing this
    Actionscript Code:
    myPopup._x;
    myPopup._y;
    or maybe this
    Actionscript Code:
    myPopup._x = _root._xmouse;
    myPopup._y = _root._ymouse;
    Last edited by angelhdz; 04-11-2012 at 06:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center