click and drag rotation (similar to qtvr)
I have an array of dials (like an oven knob). when you click one, you can drag up-down or left-right to make it rotate back and forth
HOW IS IT DOING THIS?
each dial basically a movie clip with a series of 20 or so frames, each with a different image. as you click and drag the mosue over it, it SCROLLS through the frames.
Code:
var KNOBarray:Array=new Array(knob1,knob2,knob3);
var currentKnob:MovieClip;
for (var iKNOB:uint; iKNOB< KNOBarray.length; iKNOB++) {
var KNOB:MovieClip=getChildByName(KNOBarray[iKNOB]) as MovieClip;
KNOB.buttonMode = true;
KNOB.addEventListener(MouseEvent.MOUSE_DOWN, knobPRESS);
KNOB.stop();
}
function knobPRESS(e:MouseEvent):void {
currentKnob=e.currentTarget as MovieClip;
startX = currentKnob.mouseX;
startY = currentKnob.mouseY;
startFrame = currentKnob.currentFrame;
stage.addEventListener(MouseEvent.MOUSE_MOVE, knobMOVE);
stage.addEventListener(MouseEvent.MOUSE_UP, knobRELEASE);
}
function knobRELEASE(evt:MouseEvent):void {
stage.removeEventListener(MouseEvent.MOUSE_MOVE, knobMOVE);
stage.removeEventListener(MouseEvent.MOUSE_UP, knobRELEASE);
}
function knobMOVE(evt:MouseEvent):void {
turning=true;
directionANDspeed = Math.round(((currentKnob.mouseX - startX)+(currentKnob.mouseY-startY))/15);
travelDistance = startFrame + directionANDspeed;
if (travelDistance > currentKnob.totalFrames) {
currentKnob.gotoAndStop(travelDistance % currentKnob.totalFrames);
} else if (travelDistance < 0) {
currentKnob.gotoAndStop(currentKnob.totalFrames +(travelDistance % currentKnob.totalFrames));
} else {
currentKnob.gotoAndStop(travelDistance);
}
}
i am also using a system of binary sockets like so:
to send information: socket.writeUTFBYTES("sent information");
torecieveinformation:socket.readUTFBytes(bytesAvailable){
("process recieved information");
}
i know it looks complicated but it's not, its just like using "trace"
My question is is there a way to send out a string everytime the dial hits a new frame? for example, when someone turns the dial to the right i want it to write (or trace) : "+"
and when someone turns the dial to the left i want it to write (or trac): "-"
i can figure out how to read the readUTFBytes so thats no problem, i jsut have no idea how to tell it to send out a plus sign everytime it's turned to the right, and a minus sign everytime it's turned to the left
let me know if you need more explanation