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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dial to Scroll Through List

Status
Not open for further replies.

daydreamb11

Technical User
Apr 1, 2007
2
US
Hello -

I was wondering if anyone could help me figure out how to code a script that would allow a dial that is controlled by a movie clip/mouse to scroll through a list of items.

If you think of it using a currently known UI, think of the Apple Ipod and how when you spin the navigation wheel, it moves up and down through the list of albums/songs/etc. I want mine to do a similar action. Any help would be greatly appreciated!!
 
This is tricky. The most difficult part is to create a dial user can rotate with mouse.

I wrote a quick script and it works well. Create a MovieClip with circler dial graphic. The centre point of this dial graphic needs to be at (0, 0) or it doesn't rotate around the centre. In other words if your dial is 200 x 200, you have to place it at (-100, -100) in the MovieClip. Place this MovieClip somewhere on Stage and name it "mcDial".
Code:
var isActive:Boolean;
var lastX:Number;
var lastY:Number;
var rotation:Number = 0;
this.onEnterFrame = function():Void  {
	if (isActive) {
		var difX:Number = _xmouse-lastX;
		if (_ymouse>mcDial._y) {
			difX *= -1;
		}
		lastX = _xmouse;
		rotation += difX;
		var difY:Number = _ymouse-lastY;
		if (_xmouse<mcDial._x) {
			difY *= -1;
		}
		lastY = _ymouse;
		rotation += difY;
		mcDial._rotation = rotation;
	}
};
mcDial.onPress = function():Void  {
	isActive = true;
	lastX = _xmouse;
	lastY = _ymouse;
};
mcDial.onRelease = mcDial.onReleaseOutside=function ():Void {
	isActive = false;
};
Once this is done the rest is relatively easy.

Kenneth Kawamoto
 
Hey Kenneth -

Thanks for the help! I actually got it to work, but I have been having problems having it recognize the movie clip that will recurse through the list...

I've been using the script below to figure out give a delay to the dial so that it doesn't move frames every time it recognizes whether the dial is moving clockwise or counterclockwise. It worked for awhile, when the list was on the _parent movieClip, but when I moved it to its own movieClip because it was not keeping memory of selections or deselections, it stopped working. I called the new movieClip fooBar, but it won't work...

Any suggestions?


counter = 0;
counter2 = 0;

if (direction == "clockwise") {

while (counter <= 30000 && fooBar._currentFrame < 4) {
if(counter == 30000) {
fooBar.nextFrame();
}
counter++;
}
counter = 0;
}
 
I can only guess what you're trying to do but this is what I think you're after:
Code:
if (direction == "clockwise") {
	if (counter>=30000) {
		fooBar.nextFrame();
		counter = 0;
	} else {
		counter++;
	}
}

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top