Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rotation of mc by dragging

Status
Not open for further replies.

dionysus74075

Technical User
Jun 3, 2005
11
US
OK, I have a wheel with specific values I want users to be able to see when they rotate the wheel to a certain point... the problem is that right now when you go to press and drag the wheel (which is a mc called mcMain) it jumps to a certain point then you can drag normally and it works fine... ideas? I think I need to take a different approach.


mcMain.onPress = function() {
scrolling = true;
}
mcMain.onRelease = mcMain.onReleaseOutside=function () {
scrolling = false;
}
ab = _root.createEmptyMovieClip("temp", 1)
ab.onEnterFrame = function() {
if (scrolling) {
var dx = _xmouse-mcMain._x;
var dy = _ymouse-mcMain._y;
var rad = Math.atan2(dy, dx);
if (rad<0) {
rad += Math.PI*2;
}
angle = (rad*180)/Math.PI;
mcMain._rotation = angle;

}
}
 
OK, I have a mc called (as you can see below) mcMain... it's a wheel that I want to turn and it contains specific values that I want a user to be able to scroll to.
The problem I'm having is that when you press the wheel it jumps to a certain point on the wheel rather than just beginning to drag from wherever I press... it then drags normally as you rotate it CW, CCW, 360, etc. Ideas?


mcMain.onPress=function(){
pressing=true
}
mcMain.onRelease=mcMain.onReleaseOutside=function(){
pressing=false
}
_root.onEnterFrame=function(){
if(pressing){
rad=Math.atan2((_ymouse-mcMain._y),(_xmouse-mcMain._x));
degrees=Math.round(rad*180/math.PI);
mcMain._rotation= degrees+90
}
}
 
hey
ok i tried out your code and i see what you mean

heres the fix:

1)double click to enter your mcMain movie clip

2)you should see a little + somewhere, which tells your where the movie clip origin is for its axis

3)make sure the center of your wheel graphic is aligned with the center of this +

(use the align panel for this)



 
no... the origin isn't the problem... it actually rotates the circle to another location then begins to drag... it does rotate/drag on it's origin just fine. I want it to begin drag from the location where I press and not move until I actually drag. In other words, I want to be able to press on the circle anywhere and it won't move until I begin to drag. As it is now, there is only one location on the circle where that happens and I want it to just start drag from anywhere on the circle... well, except the center I guess...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top