Problems with MOUSE position... HELP!
March 11th, 2010
Filed under: enart.xn--i1uv10c.com | edit
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;
}
};
A1 B1
A2 B2 C2
does the attached fla not provide what you want?
isnt the problem that your this._xmouse and this._ymouse are calculated relative to the button it is called from?
maybe _parent._xmouse and _parent._ymouse would be better..then they will be relative to otra_vez?
Hi there...
Thanks for the reply...
Actually i was able to solve the problem... and in a really easy way. Almost like a cheat. Some "hardcode" and that was it.
Some logic. When the cursor hover the 1st button, then i assigned x=A y=1 when hovers the 2nd button (horizontal move) x=B y=1 and so on... then display that instead of calling for the mouse function that appeared to be inconsistent.
Easy, no?
And to think that i almost killed myself for that...
But the problem is that i had to hard code EVERYTHING!
But thanks anyway...
Cheers!
Leo.
:thumb2:
But sadly i already tried that and it doesnt help...
The reason why ydir = ydir+4; and xdir = xdir+8; its because the ZERO point is located at y=-4 and x=-8.
And the _root. is not gonna help me since the variables are not at the root.
But thanks for the try.
Any other idea?
Cheers!
:thumb:
Leo.
A1 B1
A2 B2 C2
does the attached fla not provide what you want?
isnt the problem that your this._xmouse and this._ymouse are calculated relative to the button it is called from?
maybe _parent._xmouse and _parent._ymouse would be better..then they will be relative to otra_vez?
xdir = _root._xmouse;
ydir = _root._ymouse;
xdir = (xdir /10);
xdir = Math.floor(xdir);
xdir = xdir+1;
trace("ydir "+ydir);
ydir = (ydir /10);
ydir = Math.floor(ydir);
ydir = ydir+1;
#If you have any other info about this subject , Please add it free.# |