# Math.random() question

**URL:** https://forum.kirupa.com/t/math-random-question/308767
**Category:** flash
**Created:** [April 29, 2010, 6:00pm UTC](https://forum.kirupa.com/t/math-random-question/308767 "2010-04-29T18:00:05Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![captsin](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@captsin](https://forum.kirupa.com/u/captsin)
#### Post date: [April 29, 2010, 6:00pm UTC](https://forum.kirupa.com/t/math-random-question/308767/1 "2010-04-29T18:00:05Z")

</div>

Hello,

I have created a tween with actionscript that moves a movie clip of a cityscape along the x axis whenever the mouse is clicked.

This is my code

var skylineTween:Tween=new Tween(skyline\_mc,“x”, Regular.easeInOut, skyline\_mc.x,Math.floor(Math.random() \* (-1022 - -16) ) + -3,2,true);

Right now it generates a random number from between -1022 and -16 (positions along the x axis).

However, sometimes the skyline movie clip only moves a few pixels and looks boring.

I added 200 pixels to the movement (Math.random() \* (-1022 - -16) +200 ) and it looks better. However, sometimes this slides the movie clip past -1022 or -16 and off the stage.

How can I set the value to +200 without passing -1022 or -16?

Any help is greatly appretiated!

Thanks.
