# One last thing with RANDOM!

**URL:** <https://forum.kirupa.com/t/one-last-thing-with-random/4964>\
**Category:** Uncategorized\
**Created:** [August 27, 2002, 5:33am UTC](https://forum.kirupa.com/t/one-last-thing-with-random/4964 "2002-08-27T05:33:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ryall](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@Ryall](https://forum.kirupa.com/u/Ryall)\
**Post date:** [August 27, 2002, 5:33am UTC](https://forum.kirupa.com/t/one-last-thing-with-random/4964/1 "2002-08-27T05:33:21Z")

</div>

here is my final code:

onClipEvent (load) {  
speed = Math.random()\*3;  
}  
onClipEvent (enterFrame) {  
this.\_x += speed;  
if (this.hitTest(\_root.reset)) {  
this.\_x = -300;  
speed = Math.random()\*3  
this.\_y = Math.random()\*76  
this.\_alpha = Math.random()\*45  
this.xscale = Math.random()_100  
this.yscale = this.xscale_1.765  
}  
}

everything works fine EXCEPT the random scalling… any hints??? oh and I have the last line times 1.765 in order to keep proportion of the randomly scaled MC. Please help.  
Peace

PS I tried using this too:

mySize=Math.random()_100  
this.xscale=mySize  
this.yscale=mySize_1.765

Thanks

---

<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:** [August 27, 2002, 5:36am UTC](https://forum.kirupa.com/t/one-last-thing-with-random/4964/2 "2002-08-27T05:36:17Z")

</div>

Try…

```auto

onClipEvent (load) {
speed = Math.random()*3;
}
onClipEvent (enterFrame) {
this._x += speed;
if (this.hitTest(_root.reset)) {
this._x = -300;
speed = Math.random()*3;
this._y = Math.random()*76;
this._alpha = Math.random()*45;
this._xscale = Math.random()*100;
this._yscale = this._xscale*1.765;
}
}

```

You forgot to add the \_ in front of xscale and yscale

You could also use \_width and \_height instead of \_xscale and \_yscale. They do the same thing.

---

<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:** [August 27, 2002, 5:39am UTC](https://forum.kirupa.com/t/one-last-thing-with-random/4964/3 "2002-08-27T05:39:37Z")

</div>

I just caught that!!! ha, its the little things that get you… is height in pixels? or %… thank for all your help!

---

<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:** [August 27, 2002, 5:41am UTC](https://forum.kirupa.com/t/one-last-thing-with-random/4964/4 "2002-08-27T05:41:01Z")

</div>

It is in Pixels.

I hate little coding errors that can make or break your code. One friggin’ symbol is all it takes.
