header
ask question
Click here to ask Question Now Its free No registration required. Flash, Flex, Flash Media Server, ActionScript,Adobe Air. Most questions receive a response in an hour.
Saurabh

2/1/2010 1:07:40 AM

Title: Connecting rotating knob to timeline.




I have this flash rotating knob. I need to connect it to a timeline such that when I rotate the knob clockwise 1degree, the timeline goes to the next frame, and continuosly does that. Whe I rotate 1 degree anti clockwise, in the timeline it goes 1 frame back and keeps going back with every 1 degree.

The timeline will have a box zoom in(on clockwise rotate) and zoom out(on anti-clockwise)

Rotating Knob action is attached below :

handle.onPress = function(){
// when you press the grip in the handle
handle.onMouseMove = function(){
// add a mouse move event to the handle

// get an angle to the mouse using atan2 (gets radians)
var angle = Math.atan2(this._parent._ymouse-this._y,this._parent._xmouse-this._x);
// apply rotation to handle by converting angle into degrees
this._rotation = angle*180/Math.PI;
// rotate the grip opposite the handle so it won't rotate along with it
}


}
handle.onMouseUp = function(){
// if a mouse move event, delete it on mouse up
if (this.onMouseMove) delete this.onMouseMove;
}

stop();



Please help me get this right. Thank You in advance.



Inder
2/1/2010 1:55:44 AM
Hi Saurabh,

here is the solution for rotation of nob with timeline movement both clockwise and anticlockwise. It will keep moving the timeline in direction with degree continiously. Updated your onPress function code :


handle.onPress = function() {
// when you press the grip in the handle
//------- new code added by redni-----------
var prevAngle = 0;
//--------------------------------------------

handle.onMouseMove = function() {
// add a mouse move event to the handle

// get an angle to the mouse using atan2 (gets radians)
var angle = Math.atan2(this._parent._ymouse-this._y, this._parent._xmouse-this._x);
// apply rotation to handle by converting angle into degrees
this._rotation = angle*180/Math.PI;
// rotate the grip opposite the handle so it won't rotate along with it

//------- new code added by redni-----------
//checking if degree of rotation is atleast 1
if (Math.abs(Math.ceil(this._rotation-prevAngle))>1) {


if ((this._rotation-prevAngle)>1) {
//if clockwise

_root.nextFrame();
} else {
//if anticlockwise
_root.prevFrame();
}
//save previous angle
prevAngle = this._rotation;

}
//-----------------------------------
};

};


Post your Reply
Name  

Email

Type your Reply or Answer

Are you human? What is 2+5 



Members Login

Email  
Password
Forgot Password





This website focus on: Flash | Flex | FMS | RED5 | WOWZA | Flash Media Server | Adobe AIR | ActionScript,Flash Solutions | Flash Question | Flash Answers | Flash Developers | Flash Problem, Flash Help, Flash bugs, Flash workaround | Flash Blog | Flex Question Answers | Flash Forum | Flex Development | Actionscript development | Flash development | Adobe AIR development
Copyright © 2008 AskMeFlash.com. All rights reserved. Privacy Policy | Terms & Conditions