i got a MC that follows mouse movement with easing in y-axis.
this is the MC actionscript:
[AS]
onClipEvent (enterFrame) {
_y += (_parent._ymouse-_y)/5;
}
[/AS]
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?
this should do it:
[AS]
//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;
}
[/AS]
urm. it move when my mouse is on top of that MC
but it didnt follow the mouse. it just go straight down
[AS]my_mc.onRollOver = function() {
this.onEnterFrame = function() {
this._y += (this._parent._ymouse-this._y)/5;
};
};
my_mc.onRollOut = function() {
delete this.onEnterFrame;
};[/AS]
:thumb:
[edit]
[AS]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;
};
};[/AS]
That will give you a smoother onRollOut
system
July 5, 2003, 10:50pm
6
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?
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.