# Random movement

**URL:** <https://forum.kirupa.com/t/random-movement/280636>\
**Category:** Uncategorized\
**Created:** [January 29, 2009, 7:19pm UTC](https://forum.kirupa.com/t/random-movement/280636 "2009-01-29T19:19:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gencoglu](https://avatars.discourse-cdn.com/v4/letter/g/898d66/32.png) [@gencoglu](https://forum.kirupa.com/u/gencoglu)\
**Post date:** [January 29, 2009, 7:19pm UTC](https://forum.kirupa.com/t/random-movement/280636/1 "2009-01-29T19:19:04Z")

</div>

Hi, I am tring to make an object move across the screen randomly…I want it move up-down left or right acording to the values created…for example I want my object move between value (-5 and +5 ) whats wrong with this ? because it always moves downward ???  
thanks ?  
[AS]  
on(press)  
{  
dur=setInterval(kos,200);  
function kos(){  
var rn1=Math.floor(Math.random()_(5-10))+10;  
var rn2=Math.floor(Math.random()_(5-10))+10;

\_root.car.\_x+=rn1;  
\_root.car.\_y+=rn2;

kutu.text="…"+rn1+"…"+rn2;  
}}

[/AS]
