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

Making Analogue Dials

Status
Not open for further replies.

CrazyJR

Programmer
Oct 3, 2001
5
AU
How would I go about making an analogue-look dial/knob (similar to the volume control on the standard Win2k CD player) that acts as a menu in which the user drags the pointer around to a certain point around the dial and are taken to the corresponding page. Is it possible? Thanks in advance.
 
There's a couple of ways around this - depends how your trigonometry is... mine's not so good so here's a simple (but less refined) solution :)

I created a dial symbol as a movieClip with a button in it that acts as a handle to drag the dial around. On the handle I added this...

on(press){
turn=true;
oldMouse=_xmouse;
}
on(release, releaseOutside){
turn=false;
}


...then I placed the whole clip on the stage and added these actions...

onClipEvent (enterFrame) {
newMouse = _xmouse;
_root.value = math.floor((this._rotation+130)/27)+1;
if (turn && newMouse>oldMouse+5 && this._rotation<130) {
this._rotation += 5;
} else if (turn && newMouse<oldMouse-5 && this._rotation>-130) {
this._rotation -= 5;
}
}


_root.value is displayed in a textBox as a readout. You'll have to change the limits of the _rotation etc. to fit your own movie because I just threw this together and went for any kludgy value that made it work.

has an example - click the green button and drag to turn the dial (I've set it to rotate quite slowly and it sometimes goes backwards but I'm sure you can iron that out).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top