# Applying friction to movieclip

**URL:** <https://forum.kirupa.com/t/applying-friction-to-movieclip/276866>\
**Category:** Uncategorized\
**Created:** [December 4, 2008, 2:05pm UTC](https://forum.kirupa.com/t/applying-friction-to-movieclip/276866 "2008-12-04T14:05:32Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![grebs](https://avatars.discourse-cdn.com/v4/letter/g/848f3c/32.png) [@grebs](https://forum.kirupa.com/u/grebs)\
**Post date:** [December 4, 2008, 2:05pm UTC](https://forum.kirupa.com/t/applying-friction-to-movieclip/276866/1 "2008-12-04T14:05:32Z")

</div>

i have a movieclip that accelerates when you press the up button. when you let go of the up button the movieclip no longer accelerates but carries on at a constant speed. i am trying to add friction to the movieclip so it slows down when the up button is released. i have written this code -

private var friction:Number = 0.5;

stage.addEventListener(KeyboardEvent.KEY\_UP, Stop);

private function Stop(evt:KeyboardEvent):void  
{  
if(evt.keyCode == Keyboard.UP){  
xAcc = 0;  
xVel \*= friction;  
}  
}

but all this does it slow the movieclip down suddenly and makes it go at a slower constant speed. Can anyone help?
