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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Action script to change the Colour of a Graphic

Status
Not open for further replies.

Jiggerman

Programmer
Sep 5, 2002
62
GB
Hey folks,

I was hopeing that you kind people could help me.

I'm using Flash 4 to creat a teaching application for kids between 8-14. What I'm trying to achieve is being able to change the colour of an symbol, pretty simple I'm sure your saying.

i've never had to use actionscript before (short of "Stop" and "GoTo").

I'd need to use an if statement, the psedo code being something similar to:

on press
if symbol colour = red
change to green
elseif symbol colour = green
change to red
endif
end press

I was thinking of using Tint, but I can't see that in the "Set Property" option.

Any help will be greatly appreciated.

thanks very much
 
The option to change the colour of a graphic in ActionScript isn't available in Flash 4, the Color() object was introduced in version 5.

Maybe you could have different coloured versions of your graphic in consecutive frames of a movieclip (using Tint) then direct the user to the appropriare colour using gotoAndStop()?
 
Oh,

Do you think that I would be able to use 2 seperate symbols in a button. With each symbol being on a different layer with in the button. then toggle the alpha of the top symbol to be transaprent, to show through the colour below.

Do you think that this would work?

Also would it be to much trouble to ask you to advise me on the code?

I assume it would be something similar to:

on press
if visibility of topSymbol = 1
set visibility of topSymbol = 0
else
set visibility of topSymbol = 1
endif
endOn

Thanks for any help
 
I didn't do much work with Flash 4 and I'm not familiar with the syntax (it changed drastically in 5) so I can't help with the code I'm afraid.

What you suggest will work although you can't affect a button's _alpha property directly in code, the graphic will have to be a movieclip contained within the button.



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top