View Full Version : when mouse is rollOut?
Neo-Geo
July 5th, 2003, 04:16 AM
i got a MC that follows mouse movement with easing in y-axis.
this is the MC actionscript:
onClipEvent (enterFrame) {
_y += (_parent._ymouse-_y)/5;
}
but i only want it to follow the mouse only when the mouse is on top of this MC.
using that script, the MC will follow no matter where i placed the mouse.
can anyone help me to modify it?
λ
July 5th, 2003, 04:32 AM
this should do it:
//place this on the main timeline
my_mc.onRollOver = function(){
my_mc.onEnterFrame = function(){
my_mc._y += (_ymouse - _y)/5
}
}
my_mc.onRollOut = function(){
delete my_mc.onEnterFrame;
}
Neo-Geo
July 5th, 2003, 04:45 AM
urm. it move when my mouse is on top of that MC
but it didnt follow the mouse. it just go straight down
lostinbeta
July 5th, 2003, 12:00 PM
my_mc.onRollOver = function() {
this.onEnterFrame = function() {
this._y += (this._parent._ymouse-this._y)/5;
};
};
my_mc.onRollOut = function() {
delete this.onEnterFrame;
};
:thumb:
[edit]
my_mc.onRollOver = function() {
this.onEnterFrame = function() {
this._y += (this._parent._ymouse-this._y)/5;
};
};
my_mc.onRollOut = function() {
var fY = this._parent._ymouse;
this.onEnterFrame = function() {
this._y += (fY-this._y)/5;
};
};
That will give you a smoother onRollOut :)
Neo-Geo
July 5th, 2003, 12:21 PM
ok... works great. thanks
[m]
July 5th, 2003, 06:50 PM
my_mc.onRollOver = function() {
this.onEnterFrame = function() {
this._y += (_root._ymouse-this._y)/5;
};
};
my_mc.onRollOut = function() {
var fY = _root._ymouse;
this.onEnterFrame = function() {
this._y += (fY-this._y)/5;
if(this._y>(fY-.2)) delete this.onEnterFrame;
};
}; Please don't use _parent. Use _root instead. What If the mc that folows the mouse is inside another mc?
lostinbeta
July 5th, 2003, 10:03 PM
Good catch [m], thanks :) I just have a habit of not using _root, but in this case it would actually be best to use _root.
felipegm
March 3rd, 2004, 07:47 AM
This is similar of what Iīm trying to my menu.
Just one thing different.
Iīd like to make the mouse move to a _X location when a button is rollover and to get back to the previous location when rollout.
When clicked, the MC should stick in position.
Thanks any help
Seticus
March 3rd, 2004, 08:07 AM
Something like this then:
mybutton.onRollOver = function() {
var newlocation = 200;
_root.onEnterFrame = function() {
my_mc._y += (newlocation-my_mc._y)/5;
};
};
mybutton.onRollOut = function() {
var oldlocation = 50;
_root.onEnterFrame = function() {
my_mc._y += (oldlocation-my_mc._y)/5;
};
};
mybutton.onPress = function() {
delete _root.onEnterFrame;
};
You have to set the previous and new position because I don't really know what the previous position should be in your case. Does it have to be the position where it stopped or when it always goes, or where you rolled out...
felipegm
March 3rd, 2004, 08:36 AM
MC is on A position.
When mouseover, Mc goes to the button position (B), when rollout, go back to A.
If clicked, stays on position of the button clicked.
Seticus
March 3rd, 2004, 09:09 AM
mybutton.onRollOver = function() {
var newlocationx = mybutton._x;
var newlocationy = mybutton._y;
_root.onEnterFrame = function() {
my_mc._y += (newlocationy-my_mc._y)/3;
my_mc._x += (newlocationx-my_mc._x)/3;
};
};
mybutton.onRollOut = function() {
var oldlocationx = 50;
var oldlocationy = 50;
_root.onEnterFrame = function() {
my_mc._y += (oldlocationY-my_mc._y)/5;
my_mc._x += (oldlocationx-my_mc._x)/3;
};
};
mybutton.onPress = function() {
delete _root.onEnterFrame;
};
should give you what you want
felipegm
March 3rd, 2004, 09:22 AM
almost getting it.
But even after clicking the button, the Mc goes back to the original position.
felipegm
March 3rd, 2004, 09:25 AM
this is the fla I making to test it.
Could you please take a look to see what Iīm doing wrong?
Thx
Seticus
March 3rd, 2004, 10:04 AM
pressed = false;
botao1.onRollOver = function() {
var newlocationx = -290;
var newlocationy = 0;
_root.onEnterFrame = function() {
mc._y += (newlocationy-mc._y)/3;
mc._x += (newlocationx-mc._x)/3;
};
};
botao1.onRollOut = function() {
if (pressed == false) {
var oldlocationx = 0;
var oldlocationy = 0;
_root.onEnterFrame = function() {
mc._y += (oldlocationY-mc._y)/5;
mc._x += (oldlocationx-mc._x)/3;
};
} else {
pressed = false;
}
};
botao1.onPress = function() {
delete _root.onEnterFrame;
pressed = true;
};
felipegm
March 3rd, 2004, 12:06 PM
I tried this code and works fine,
but if we click on the button before Mc gets on it, the MC stops. Itīs should make the same way to that button as on rollover, and as soon it gets there, it stops.
Seticus
March 3rd, 2004, 12:20 PM
oh, I misunderstood that:
here's the new script:
pressed = false;
oldlocationx = mc._x;
oldlocationy = mc._y;
newlocationx = botao1._x;
newlocationy = botao1._y;
botao1.onRollOver = function() {
_root.onEnterFrame = function() {
mc._y += (newlocationy-mc._y)/3;
mc._x += (newlocationx-mc._x)/3;
};
};
botao1.onRollOut = function() {
if (pressed == false) {
_root.onEnterFrame = function() {
mc._y += (oldlocationY-mc._y)/5;
mc._x += (oldlocationx-mc._x)/3;
};
} else {
pressed = false;
}
};
botao1.onPress = function() {
pressed = true;
oldlocationx = newlocationx;//here you change the position to go to
oldlocationy = newlocationy;//so it stays and will return to the new location
};
check the attachement
felipegm
March 3rd, 2004, 12:47 PM
Thanks a lot man!
Now I cam see how itīs done.
Seticus
March 3rd, 2004, 01:01 PM
ur welcome
felipegm
March 3rd, 2004, 01:01 PM
I forgot asking you that, but can I use this code on both buttons?
What lines I have to change?
Seticus
March 3rd, 2004, 01:05 PM
propably something like this:
pressed = false;
oldlocationx = mc._x;
oldlocationy = mc._y;
botao1.onRollOver = function() {
newlocationx = botao1._x;
newlocationy = botao1._y;
_root.onEnterFrame = function() {
mc._y += (newlocationy-mc._y)/3;
mc._x += (newlocationx-mc._x)/3;
};
};
botao1.onRollOut = function() {
if (pressed == false) {
_root.onEnterFrame = function() {
mc._y += (oldlocationY-mc._y)/5;
mc._x += (oldlocationx-mc._x)/3;
};
} else {
pressed = false;
}
};
botao1.onPress = function() {
pressed = true;
oldlocationx = newlocationx;
oldlocationy = newlocationy;
};
botao2.onRollOver = function() {
newlocationx = botao2._x;
newlocationy = botao2._y;
_root.onEnterFrame = function() {
mc._y += (newlocationy-mc._y)/3;
mc._x += (newlocationx-mc._x)/3;
};
};
botao2.onRollOut = function() {
if (pressed == false) {
_root.onEnterFrame = function() {
mc._y += (oldlocationY-mc._y)/5;
mc._x += (oldlocationx-mc._x)/3;
};
} else {
pressed = false;
}
};
botao2.onPress = function() {
pressed = true;
oldlocationx = newlocationx;
oldlocationy = newlocationy;
};
felipegm
March 3rd, 2004, 03:29 PM
Itīs great!
Thanks
One more thing.
Can I make a button inside a MovieCLip (another one) to control the MC?
Seticus
March 3rd, 2004, 03:44 PM
sure, just place in front of the name of your button
e.g. botao2 make that: nameofthemc.botao2
felipegm
March 4th, 2004, 08:14 AM
I tried doing that...
botao2.onRollOver = function() {
newlocationx = botao2._x;
newlocationy = botao2._y;
_root.onEnterFrame = function() {
mc._y += (newlocationy-mc._y)/5;
mc._x += (newlocationx-mc._x)/5;
mc._xscale = 206;
};
};
nameofmc.button3.onRollout = function() {
if (pressed == false) {
_root.onEnterFrame = function() {
mc._y += (oldlocationY-mc._y)/5;
mc._x += (oldlocationx-mc._x)/3;
mc._xscale = oldscale;
};
} else {
pressed = false;
}
};
botao2.onPress = function() {
pressed = true;
oldlocationx = newlocationx;
oldlocationy = newlocationy;
oldscale = 206;
};
Itīs werd cus it works on the first mouse out, but not on the second mouseout.
If I click on button5, and then on the button on that movieclip the MC dontīgo back to oldlocation.
Sorry man for bothering for so long, but Iīm perfecionist and this consuming a long time since Iīm still learning AS for this kind of menu.
felipegm
March 4th, 2004, 08:24 AM
I think I figure out.
Maybe itīs because that button has other action on it controling itself.
Iīll work more on that.
Thanks
Seticus
March 4th, 2004, 12:20 PM
I don't understand what you are trying to do here.
What should happen when you click on the mc "botao2"?
felipegm
March 6th, 2004, 10:59 AM
I want this:
All of my menu buttons have to make MC to move in rollover, and to move to oldlocation when rollout. And stay when pressed. Thatīs OK.
Thatīs what Iīm not getting yet.
In one of my buttons, "Portfolio", Iīd like to make it like a dropdown menu: When its rollover, some other buttons appear bellow it.
For exemple: on mouse over Portfolio, will appear WEB, Picture and Drawing bellow it as three options for a dropdown menu.
So as the dropdown menu is showing, the Mc should remain on Portfolio button highlighting it. If the user doesnīt click in any option (WEB, Picture, Drawing) and goes outside the dropdown menu, the MC goes to oldlocation.
I the user clicks in any option, the MC stays highlighting Portfolio.
I belive the only action on Portfolio should be on (rollOver),
The other actions (rollOut and OnPress) should go on the Options below (WEB, Picture, Drawing).
Hope have been clear.
Thanks
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.