HI there… I am trying to get the mouse position when u hover a button. The problem is that when u hover the same button vertically it gives the wrong position while when u do it horzontal, it works fine.
I tried and tried to c what was wrong, but no idea so far.
So if u guys could help, that would be nice.
Here is the code, and the *.fla is attached.
Cheers
Leo
:player:
//function called to c where is the mouse, and get its position
where = function()
{
xdir = this._xmouse;
ydir = this._ymouse;
xdir = (xdir /10);
xdir = Math.floor(xdir);
xdir = xdir+8;
ydir = (ydir /10);
ydir = Math.floor(ydir);
ydir = ydir+4;
// I am dividing the x position up to H. While the y position continues the same
if (xdir == 1)
{
xdir ="A";
}
if (xdir == 2)
{
xdir ="B";
}
if (xdir == 3)
{
xdir ="C";
}
if (xdir == 4)
{
xdir ="D";
}
if (xdir == 5)
{
xdir ="E";
}
if (xdir == 6)
{
xdir ="F";
}
if (xdir == 7)
{
xdir ="G";
}
if (xdir == 8)
{
xdir ="H";
}
};
//call the first button.
cap._visible = false;
b1.onRollOver = function() {
where();
captionFN(true, xdir+" "+ydir, this);
this.onRollOut = function() {
captionFN(false);
};
};
//call the second button.
b2.onRollOver = function() {
where();
captionFN(true, xdir+" "+ydir, this);
this.onRollOut = function() {
captionFN(false);
};
};
//call the third button.
b3.onRollOver = function() {
where();
captionFN(true, xdir+" "+ydir, this);
this.onRollOut = function() {
captionFN(false);
};
};
//call the forth button.
b4.onRollOver = function() {
where();
captionFN(true, xdir+" "+ydir, this);
this.onRollOut = function() {
captionFN(false);
};
};
//call the fifth button.
b5.onRollOver = function() {
where();
captionFN(true, xdir+" "+ydir, this);
this.onRollOut = function() {
captionFN(false);
};
};
captionFN = function (showCaption, captionText, bName) {
if (showCaption) {
this.createEmptyMovieClip("hoverCaption", this.getNextHighestDepth());
cap.desc.text = captionText;
cap._width = 7*cap.desc.text.length;
cap._alpha = 75;
//
if ((bName._width+bName._x+cap._width)>Stage.width) {
xo = -2-cap._width;
yo = -17;
} else {
xo = 2;
yo = -17;
}
hoverCaption.onEnterFrame = function() {
cap._x = this._xmouse+xo;
cap._y = this._ymouse+yo;
cap._visible = true;
};
} else {
delete hoverCaption.onEnterFrame;
cap._visible = false;
}
};