Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change color of rectangle based on word in textfield

Status
Not open for further replies.

nitrokid

Technical User
Sep 14, 2005
89
GB
Hi

I have a textarea (st1a) and a red rectangle above it (st1b). When the word 'England' is entered into st1a, I want st1b to change to Green. When anything else is entered into st1a, then st1b should be red

I've tried this :

on(change){
if (st1a.text == "England") {
_root.st1b.setRGB(0x66CC33);
} else {
_root.st1b.setRGB(0xFF0000);
}
}

However, othing happens when I enter England into the textarea. The rectangle just remains red. I am very new to actionscript and flash, so I wouldn't be suprised if I've got it totally wrong

Any help would be much appreciated
 
code on main timeline do not attach to textarea or rectangle movie clip

var listen:Object = new Object();
listen.change = function(obj) {
if (obj.target.text == "England") {
clipColor = new Color(st1b);
clipColor.setRGB(0x66cc33);
} else {
clipColor = new Color(st1b);
clipColor.setRGB(0xFF0000);
}
};
st1a.addEventListener("change", listen);

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top