# What's wrong with this script

**URL:** <https://forum.kirupa.com/t/whats-wrong-with-this-script/13505>\
**Category:** Uncategorized\
**Created:** [February 13, 2003, 11:26pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505 "2003-02-13T23:26:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![shuga](https://avatars.discourse-cdn.com/v4/letter/s/a9adbd/32.png) [@shuga](https://forum.kirupa.com/u/shuga)\
**Post date:** [February 13, 2003, 11:26pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/1 "2003-02-13T23:26:57Z")

</div>

i have this script attatched to a blank mc on it’s own layer

```auto

onClipEvent (load) {
	_root.mm.tech.setProperty._alpha = (Math.random(100))+30;
	_root.mm.design.setProperty._alpha = (Math.random(100))+30;
	_root.mm.contact.setProperty._alpha = (Math.random(100))+30;
	_root.mm.fun.setProperty._alpha = (Math.random(100))+30;
}

```

the paths are correct … i want the alpha to be random it’d be nice if it were between like 30 and 100 … but this is the best i can do. i don’t want it to fluctuate … just to be set once when the movie loads does that make sense

if you want to see the movie to understand better you can get it at [http://www.aaronsleeper.com/bleh.fla](http://www.aaronsleeper.com/bleh.fla)

–edit–

i looked in the AS dictionary in the help section of Flash and i thought i should change the script to

```auto

onClipEvent (load) {
	_root.mm.tech.setProperty(_alpha, Math.random(100)+30);
	_root.mm.design.setProperty(_alpha, Math.random(100)+30);
	_root.mm.contact.setProperty(_alpha, Math.random(100)+30);
	_root.mm.fun.setProperty(_alpha, Math.random(100)+30);
}

```

but it’s still not working ☹

---

<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 13, 2003, 11:52pm UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/2 "2003-02-13T23:52:16Z")

</div>

well i figured it out  
it should look like this

```auto

onClipEvent (load) {
	setProperty("_root.mm.tech", _alpha, Math.random(100)+30);
	setProperty("_root.mm.design",_alpha, Math.random(100)+30);
	setProperty("_root.mm.contact",_alpha, Math.random(100)+30);
	setProperty("_root.mm.fun",_alpha, Math.random(100)+30);
}

```

but now it takes over the other actions of the buttons for my movie @#$!$@%)!@$%\_) and they don’t move like they’re supposed to

_sigh_ i’ll keep workin on it :sure:

---

<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 14, 2003, 12:31am UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/3 "2003-02-14T00:31:43Z")

</div>

Why use set property??? Also your Math.random statements are written wrong.

```php
onClipEvent (load) {
	_root.mm.tech._alpha = Math.floor(Math.random()*(100-30)+30);
	_root.mm.design._alpha = Math.floor(Math.random()*(100-30)+30);
	_root.mm.contact._alpha = Math.floor(Math.random()*(100-30)+30);
	_root.mm.fun._alpha = Math.floor(Math.random()*(100-30)+30);
}

```

You can learn more on random numbers here…  
[http://www.kirupa.com/developer/actionscript/tricks/random.asp](http://www.kirupa.com/developer/actionscript/tricks/random.asp)

---

<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 14, 2003, 12:33am UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/4 "2003-02-14T00:33:00Z")

</div>

what does math.floor do … why not setProperty

beta you gotta help me with my other problem i’ve posted … it’s driving me batty

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:** [February 14, 2003, 12:35am UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/5 "2003-02-14T00:35:30Z")

</div>

and when i add that script … it still stops the other animations ☹

so it still doesn’t work

---

<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 14, 2003, 12:35am UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/6 "2003-02-14T00:35:38Z")

</div>

Your other problem is driving me batty as well.

setProperty, although still used, isn’t use as often, it is easier with the new dot syntax.

The Math.floor rounds your number down so you won’t get a value with 8 decimal places.

Math.floor() rounds down  
Math.ceil() rounds up  
Math.round() rounds off, but I think this one makes certain random numbers occur more often. I forget the EXACT reason floor is used more often. Senocular posted a lengthy explanation on this, if I find the thread, I will post it.

---

<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 14, 2003, 12:37am UTC](https://forum.kirupa.com/t/whats-wrong-with-this-script/13505/7 "2003-02-14T00:37:14Z")

</div>

Here is Sens excellent explanation on Random Numbers… Kirupas tutorial is good too.

[http://www.kirupaforum.com/showthread.php?s=&threadid=11686](http://www.kirupaforum.com/showthread.php?s=&threadid=11686)
