onClipEvent (enterFrame)/Array misery

[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]

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

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

or

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

depending on where your clip sits :slight_smile:

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 :wink:

I meant that in a general way :wink: