Link to home
Create AccountLog in
Avatar of crescue
crescue

asked on

change background color with actionscript in flash

Hi, how can I change the background color of a square (it could be a button, movieclip or graphic).
Here is what I want to do. I have created 20 squares with numbers (from 1 to 20), and when the user clicks on a square, it will change its background color. This has to be done with actionscript because I want to be able to save the changed background squares (I will take care of that later)

Thanx for any input
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

What version of Actionscript do you plan to use ?
here's a sample that uses AS2

change-colour-as2.fla
Avatar of crescue
crescue

ASKER

AS2, and I am getting unexpected file format
I am using CS3

Thanx
ASKER CERTIFIED SOLUTION
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of crescue

ASKER

can you know the color of the tile before changing it ?
(to know which color is was beforehand)

Thanx ur solution works as expected !  :)
Avatar of crescue

ASKER

I've requested that this question be closed as follows:

Accepted answer: 0 points for crescue's comment http:/Q_27189334.html#36162836

for the following reason:

Great !!!
Avatar of crescue

ASKER

I made a mistake while pressing to AWARD the earned points to QUIZENGINE

QUIZENGINE solution was perfect !!!

I cannot find how to cancel MY error !!!
Avatar of crescue

ASKER

can you know the color of the tile before changing it ?
(to know which color is was beforehand)

Thanx ur solution works as expected !  :)
Thanks for the award, but I'm unclear if you still need some clarification - do you, and if you do what is it that you need explaining ?
Avatar of crescue

ASKER

Everything is working great. My only OTHER question was : If I can know in advance which color the TILE was. For examle if it was purple, red, yellow, etc... BEFORE changing the color

Thanx
It is possible to 'sample' the colour in a shape using actionscript, but it is a bit complex.

I would say that it is far easier to create an array that holds the initial colours, and then whenever the colour gets changed, just update the array as well.