Play animation with dragged mouse

Hello,

I have got a model of an arrow and bow. There is an animation, where the bowstring is pulled back maximum, to save maximum energy for the arrow to shoot. What Scripting possibilities do I have, if I wanted the pull-back animation only to play, if the mouse is being dragged in negative y direction (Function: OnMouseDrag()). I want the animation to stop, once the mouse has been released, so that the arrow flies according to the force on the bow string…how can I achieve this?
Thanks in advance!

You can set the time of an animation by using its AnimationState

Instead of playing the animation you can set the time in an Update function with something like this

var forceScale:float = //set this to something between 0 and 1 according to the mouse drag

var animState:AnimationState = objectWithAnimation.animation["animationName"] as AnimationState;

animState.time = forceScale * animState.length; //forceScale sets the time to be a part of the total length of the AnimationState