Hey everyone,
I came up with two simple functions for determining the direction the mouse is moving, and I’m wondering if you all have an easier way of doing this:
vertical_check = function () {
j = 0;
v = [];
this.createEmptyMovieClip("tempy", this.getNextHighestDepth());
tempy.onMouseMove = function() {
j++;
v[j] = this._ymouse;
if (j>1) {
if (v[j]>v[j-1]) {
trace("moving down");
j = 0;
v = [];
} else {
trace("moving up");
j = 0;
v = [];
}
}
};
};
horizontal_check = function () {
i = 0;
h = [];
this.createEmptyMovieClip("tempx", this.getNextHighestDepth());
tempx.onMouseMove = function() {
i++;
h* = this._xmouse;
if (i>1) {
if (h*>h[i-1]) {
trace("moving right");
i = 0;
h = [];
} else {
trace("moving left");
i = 0;
h = [];
}
}
};
};
horizontal_check();
vertical_check();
This isn’t necessarily a bug fix, for my above code works. It just seems too complicated for something so simple. I’m planning on making this into a quick tutorial, so be warned that I may use your suggestions (with credit) in my writeup
Thanks!
Kirupa :beam: