-
MC to Follow Mouse Horizantially - ASAP Help
I am trying to make a menu bar that when the mouse moves around from button to button it has a bar that follows under the text.I have found scripts for making a MC follow a mouse around the screen but I cant find anything for what I need. Can anyone help me with this, I need this asap because it is for a project Im working on for school. I would appreciate any help
Thanks Chris
-
Why not put the menu into a movie clip and use the same code you found?
-
-
Why don't you just make the menu bar into a movie clip and has its x coordinate follows the mouse?
-
Senior Member
ok so maybe something like this:
Actionscript Code:
btn1.addEventListener(MouseEvent.MOUSE_OVER,runCode); btn2.addEventListener(MouseEvent.MOUSE_OVER,runCode); btn3.addEventListener(MouseEvent.MOUSE_OVER,runCode);
function runCode(evt:MouseEvent){ var tween:Tween = new Tween(myBar,"x",Strong.easeInOut,myBar.x,evt.currentTarget.x,1.5,true); }
this is just an example. it moves your bar from its current location to the button you mouse over. i assume you wanted it to move over to the button rather then just appear there?
if you want it to just appear there then use this:
Actionscript Code:
btn1.addEventListener(MouseEvent.MOUSE_OVER,runCode); btn2.addEventListener(MouseEvent.MOUSE_OVER,runCode); btn3.addEventListener(MouseEvent.MOUSE_OVER,runCode);
function runCode(evt:MouseEvent){ myBar.x=evt.currentTarget.x; myBar.y=evt.currentTarget.y; }
anyways hope this has helped you
-
PHP Code:
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
// bar.x = stage.mouseX; // no easing
bar.x -= (bar.x - stage.mouseX) / 2.5; // Zeno's paradox easing
});
Please use [php] or [code] tags, and mark your threads resolved 8)
-
Originally Posted by neznein9
PHP Code:
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
// bar.x = stage.mouseX; // no easing
bar.x -= (bar.x - stage.mouseX) / 2.5; // Zeno's paradox easing
});
Awesome thanks this worked..
-
what code would I add that once my mouse left the stage the bar goes back to a certain X value? I appreciate your help with this.
-
Give this a try
PHP Code:
var barTarget:Number = 250;
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
if(stage.mouseX < 0 || stage.mouseX > stage.stageWidth) return;
barTarget = stage.mouseX;
});
stage.addEventListener(Event.MOUSE_LEAVE, function(e:Event):void{
barTarget = 250;
});
stage.addEventListener(Event.ENTER_FRAME, function(e:Event):void{
bar.x -= (bar.x - barTarget) / 2.5;
});
Please use [php] or [code] tags, and mark your threads resolved 8)
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
|