# Animation width random startposition

**URL:** https://forum.kirupa.com/t/animation-width-random-startposition/12513
**Category:** Uncategorized
**Created:** [February 1, 2003, 1:32am UTC](https://forum.kirupa.com/t/animation-width-random-startposition/12513 "2003-02-01T01:32:46Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![Jumpman](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@Jumpman](https://forum.kirupa.com/u/Jumpman)
#### Post date: [February 1, 2003, 1:32am UTC](https://forum.kirupa.com/t/animation-width-random-startposition/12513/1 "2003-02-01T01:32:46Z")

</div>

Im a 100% beginner in actionscript so heres my question, as dumb as it may sound.

I want a shape to travel from px 0 on the x-axis to px 740.

The startposition on the y-axis needs to be random, and between  
140 and 180.

I have tried the following code:

startY = Math.round(Math.random()\*(180-140)+140);  
startX = 0;

targetX = 740;  
targetY = startY;

\_parent.\_x = startX;  
\_parent.\_y = startY;

Any help will be greatly appreciated

---

<div class="post-metadata">

### Author: ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)
#### Post date: [February 1, 2003, 2:41am UTC](https://forum.kirupa.com/t/animation-width-random-startposition/12513/2 "2003-02-01T02:41:02Z")

</div>

onClipEvent(load){  
y=Math.random()\*40+140;  
}  
onClipEvent (enterFrame) {  
var x=x+1;  
this.\_x=x;  
this.\_y=y;

}  
this will work on a clip with timeline 1 frame.  
You really don’t need to round it, and you can adjust the speed from 1 to anything you want.  
Math.random produces a number between 0 and 1.
