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
Adobe FlashScripting Languages

Avatar of undefined
Last Comment
quizengine
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

What version of Actionscript do you plan to use ?
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

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

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of crescue
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
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
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
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 quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

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
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
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
Scripting Languages
Scripting Languages

A scripting language is a programming language that supports scripts, programs written for a special run-time environment that automate the execution of tasks that could alternatively be executed one-by-one by a human operator. Scripting languages are often interpreted (rather than compiled). Primitives are usually the elementary tasks or API calls, and the language allows them to be combined into more complex programs. Environments that can be automated through scripting include software applications, web pages within a web browser, the shells of operating systems (OS), embedded systems, as well as numerous games. A scripting language can be viewed as a domain-specific language for a particular environment; in the case of scripting an application, this is also known as an extension language.

30K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo