# onClipEvent (enterFrame)/Array misery

**URL:** https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384
**Category:** flash
**Created:** [August 27, 2004, 10:57am UTC](https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384 "2004-08-27T10:57:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Pup\_100](https://avatars.discourse-cdn.com/v4/letter/p/da6949/32.png) [@Pup\_100](https://forum.kirupa.com/u/Pup_100)
#### Post date: [August 27, 2004, 10:57am UTC](https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384/1 "2004-08-27T10:57:02Z")

</div>

[font=Times New Roman]I’ve got the following simple script in the first keyframe of my movie & the appropriate text field & clip on stage.[/font]

[font=Times New Roman][color=red]cols=[0x2915B9,0xA62445,0xA4B812,0x09C14E][/color][/font]

[font=Times New Roman][color=red]my\_color=new Color(my\_clip);[/color][/font]

[font=Times New Roman]On my movie Clip (my\_clip) I have the following script:[/font]

[font=Times New Roman][color=red]onClipEvent (enterFrame) {yet=Math.floor(Math.random()\*4)[/color][/font]

[font=Times New Roman][color=red]my\_color.setRGB(cols[Number(yet)])[/color][/font]

[font=Times New Roman][color=red]\_root.lippy\_txt.text=yet;[/color][/font]

[font=Times New Roman][color=red]}[/color][/font]

[font=Times New Roman]Although when testing the text field displays the appropriate numbers, the clip instance does not change color?[/font]

[font=Times New Roman]Could anyone point out where I’m going wrong & then point out the nearest drug store so I can buy some headache pills?[/font]

[font=Times New Roman]Thank you.[/font]

---

<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, 2004, 12:30pm UTC](https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384/2 "2004-08-27T12:30:31Z")

</div>

Hello,

This is THE most common error you can have with Flash: the scope error. You’re trying to access the ‘cols’ array from within the enterFrame, but since you didn’t specify any scope, Flash will look in ‘this’ aka the current clip, which doesn’t contain anything called that. So you need to write

```auto
my_color.setRGB (_parent.cols[yet]) ;

```

or

```auto
my_color.setRGB (_root.cols[yet]) ;

```

depending on where your clip sits 🙂

---

<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, 2004, 12:50pm UTC](https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384/3 "2004-08-27T12:50:48Z")

</div>

Thank you Ilyas for you extensive & informative reply.

I take it that your Greek reference on the foot of your post will be updated? or are you playing them in the Olympics 😉

---

<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, 2004, 2:23pm UTC](https://forum.kirupa.com/t/onclipevent-enterframe-array-misery/62384/4 "2004-08-27T14:23:04Z")

</div>

I meant that in a general way 😉
