-
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
-
PHP Code:
container_mc.addEventListener(MouseEvent.ROLL_OVER, onRollOverHandler);
container_mc.buttonMode = true; container_mc.useHandCursor = true;
var myPopup:DisplayObject = new mouseovermenu(); myPopup.addEventListener(MouseEvent.MOUSE_DOWN, popupMouseDown, false, 0, true); myPopup.addEventListener(MouseEvent.MOUSE_UP, popupMouseUp, false, 0, true);
function onRollOverHandler(myEvent:MouseEvent){ addChild(myPopup); myPopup.x = mouseX; myPopup.y = mouseY; }
function popupMouseDown(e:MouseEvent) { stage.addEventListener(MouseEvent.MOUSE_MOVE, popupMouseMove, true, 0, true); stage.addEventListener(MouseEvent.MOUSE_MOVE, popupMouseMove, false, 0, true); }
function popupMouseUp(e:MouseEvent) { stage.removeEventListener(MouseEvent.MOUSE_MOVE, popupMouseMove, true); stage.removeEventListener(MouseEvent.MOUSE_MOVE, popupMouseMove, false); }
function popupMouseMove(e:MouseEvent) { var p:Point = this.globalToLocal(new Point(e.stageX, e.stageY)); myPopup.x = p.x; myPopup.y = p.y; }
Or look up startDrag and stopDrag functions... Depends on what else you want to do with it i guess...
-
Designer, Programmer, Musician
try fixing this 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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|