dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: Snapping mouse to position of Movieclip

Hybrid View

  1. #1
    Junior Member
    Join Date
    Jan 2018
    Posts
    29

    Snapping mouse to position of Movieclip

    Hello everyone, I have been trying to get the mouse to snap to the position of a movieClip once the movieClip is made visible. My approach was to define the coordinates of the mouse as that of the said movieClip however it seems flash does not dig my approach; see code below. So I would like to know weather it is possible and if so, how do I go about it. Thanks.

    Code:
    Stage_mc.addEventListener(MouseEvent.CLICK, showTaskTray);
    
    function showTaskTray(myEvent:MouseEvent):void { 
        taskManager.gotoAndPlay("Launch");
    	mouseX = taskManager.taskRibbon.x;
    	mouseY = taskManager.taskRibbon.y;
    }

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    893
    you could do it with fake cursor
    who is this? a word of friendly advice: FFS stop using AS2

  3. #3
    Junior Member
    Join Date
    Jan 2018
    Posts
    29

    Red face

    Lolll, that hack was a such smart one that I laughed immediately I saw it. Thanks much. I will try it out

  4. #4
    Junior Member
    Join Date
    Jan 2018
    Posts
    29
    Erm, it didn't work as expected; the fake cursor movieclip snap to the position of the position of the taskManager_mc once it was made visible but once I moved my mouse, the fake cursor snapped back to the original position

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    893
    Maybe you could make actual arrow mc a child of the one that is following the mouse, and then offset it from 0,0 inside once your stuff becomes visible - then this offset will remain after you move the mouse.
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Junior Member
    Join Date
    Jan 2018
    Posts
    29
    So are you suggesting I make a second cursor and put into the current cursor movieclip as a child or re-convert the current cursor_mc into movieclip and make the x and Y cordinates 0?

  7. #7
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    893
    basically, this:
    cursor_mc (no graphics, just a wrapper) <- call startDrag on this one
    arrow_mc (arrow graphics, child of cursor_mc) <- starts at 0,0; move it when you need to snap the arrow to something
    who is this? a word of friendly advice: FFS stop using AS2

  8. #8
    Junior Member
    Join Date
    Jan 2018
    Posts
    29
    Nope, I still got nothing....

  9. #9
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    893
    well, too bad. these days people send cars to Mars, and you can't get the fake cursor working
    who is this? a word of friendly advice: FFS stop using AS2

  10. #10
    Junior Member
    Join Date
    Jan 2018
    Posts
    29
    I'm not convinced that they have got a car on mars until I see sufficient proof, nothing is for sure these days. Thanks anyway for your help, I will try figure something out.

Tags for this Thread

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