Here is the way I would suggest solving your problem, this method realies heavily on ActionScripting so you don't have tons of tweens or additional objects you don't need.
See Demos and source at:
gauge/">http://www.XXdream
First though you need to solve the math part of this which will make the programming and implementation pretty simple.
So your dial is going to rotate based on a value from 0-100, you need an expression that will convert 0-100 into a valid angle for the needle to point to. For instance if you want to have 0-100 represent a dial that goes from 0 all the way around to 360 degrees you need a simple formula like "angle = value * 3.6" Where angle is the direction to point the needle and value is the text field variable. On the other hand a more realistic gauge could be like the oil gauge in your car which usually point -30 to +30 degrees from vertical, if you wanted to move a needle in a gauge like that you would first find the total range of the needle, in this case it's 60 degrees, so now your formula would be "angle = value * 0.6" resulting in a angle range of 0-60 for value inputs of 0-100. Hopefully now you can see the first part which is converting your values to an appropriate angle range. To keep this part simpler however, I'm going to imagine the needle range is 100 degrees, going from an angle of -50 to 50.
Now to start creating this make a movie clip which is your indicator arrow, make sure the registration point is the spot the needle will rotate around. Set the rotation of the needle in the movie clip to left most point the needle will start from, i.e., 0 on the gauge, in this case I'm using -50 degree rotation. It's very important you rotate the needle in the movie clip and that you do not rotate the actual movie clip.
Now in your movie clip make another layer on top of your art for the actions. In the first frame you will need the following actions:
If (/:value > _rotation)
Set Variable: "angle" = (/:value - _rotation) * .2 + _rotation + 1
Set Property ("", Rotation) = Int(angle)
Else If (/:value < _rotation - 1)
Set Variable: "angle" = _rotation - ((_rotation - /:value) * .2) - 1
Set Property ("", Rotation) = Int(angle)
End If
In the second frame you just need one action:
Go to and Play (1)
The basis of what is going is that the script calculates how far it has to go and than applies a fraction of that to the current angle. I've made samples available for download and viewing at:
gauge/">http://www.XXdream
needle1 uses the above method with a angle range of 100 and accelerated movement based on distance.
needle2 uses a 180 degree range and linear movement.
Both set a variable in the main timeline called value to a random number between 0-100 to test the movement. It is very important that you uses a variable text field called value in your main timeline in order for the gauge to respond.
Main Topics
Browse All Topics





by: BillystyxPosted on 2005-03-20 at 23:39:35ID: 13589138
As in a speedometer or tacometer of a car? something like this will make it spin according to a measure - but you need to be able to convert your measurements into 180 + or - to do it. Is it going up and down on the dial or just up, How is this happening, (user, variables from your action script? I would say we need more info on what you have to help:)
onClipEvent(enterFrame){
if(_rotation<xspeed){
_rotation +=10;
}
}
Billystyx