and the hand goes all crazy when i move the mouse exept when i touch it
and what i want is to be able to drag it to a number of the clock face .:+) :player: :cowboy: :thumb:
onClipEvent(load){
// set a center point to rotate around
this.center = {
_x: 150,
_y: 150
}
// the radius of the rotation around the center
this.radius = 100;
// a function to rotate the movieclip around the
// center at the distance of the radius. x and y
// values can be passed to point at, otherwise
// the rotation goes to the mouse
this.position = function(x,y){
// assign x and y to the mouse locations if
// they arent passed (x is undefined if not passed)
if (x == undefined){
x = this._parent._xmouse-this.center._x;
y = this._parent._ymouse-this.center._y;
}
// develop an angle from x and y
var angle = Math.atan2(y,x);
// position the clip based on that angle (trig)
this._x = this.center._x + Math.cos(angle)*this.radius;
this._y = this.center._y + Math.sin(angle)*this.radius;
}
// start the movie off rotated to be straight up (y at -1)
this.position(0,-1);
}
on(press){
// when pressed, set the onMouseMove function to be position
this.onMouseMove = this.position;
}
on(release, releaseOutside){
// when you let go, delete the onMouseMove to prevent
// further positioning
delete this.onMouseMove;
}
thats for non rotational dragging in a circular path (movement involved) if you just want the rotation aspect, which the clock hand example would be, then youd reduce that above example into just this:
onClipEvent(load){
this.position = function(x,y){
// assign x and y to the mouse locations if
// they arent passed (x is undefined if not passed)
if (x == undefined){
x = this._parent._xmouse-this._x;
y = this._parent._ymouse-this._y;
}
// develop an angle from x and y
var angle = Math.atan2(y,x);
// assign rotation based on that angle converting it
// from radians to degrees
this._rotation = angle*180/Math.PI;
}
// start the movie off rotated to be straight up (y at -1)
this.position(0,-1);
}
on(press){
// when pressed, set the onMouseMove function to be position
this.onMouseMove = this.position;
}
on(release, releaseOutside){
// when you let go, delete the onMouseMove to prevent
// further positioning
delete this.onMouseMove;
}
(BTW 0 rotation assumes pointing to the right so when it rotates to the mouse, the direction facing to the right normally will point to the mouse)
Hey! I’m trying to use the AS Senocular did and I’m not getting any results. Where to I have to put the code? Is it a btn inside a mc? Or a mc inside a btn? Can u explain it for me, please? Thanks