ActionScript 3.0 :: Use A Variable To Set The Color Of Text?
Aug 1, 2009
I want to use a variable to set the color of text and graphics input by the user. I use the following code to set the variable:
var setColor:String;setColor = "0xff0000";
strokeColorBtn_mc.addEventListener(MouseEvent.MOUSE_UP, setStrokeColor);
function setStrokeColor(event:MouseEvent):void { setColor = "0xCCCCCC"; trace ("the new color is " + setColor);}
This works, and I am able to use the variable to set the color of type in a text field:
textFormat.color = setColor;
But when I try and use the variable to set the color of a graphic element:
I have a dynamic textfield that displays different text. What I want is the ability to control both the text color and the background color of the textfield.
So i'm working on this website and I want to be able to switch out the entire color scheme on the website everytime a button is pressed, I've stepped away from flash for awhile and actionscript 3 is new me. Plus I haven't quite found any truely useful stuff on forums yet.
What i can't figure out is when a button is pressed the HTML background color changes to one of 5 preselected colors (that alternate ever time the button is pressed). Then for each background change the text changes too as it is part of a entire new color scheme.
What I've managed so far is to change the color of the background thats within the Flash file. What i did was to make a movie clip that plays to a next frame and stop everytime the button is pressed. Now i just need to also get to change the HTML color and the font colors.
//"homeText" being the name of dynamic text field and "Button" the name of the button and "background" being the movie clip that is the background within the flash file.
Button.addEventListener(MouseEvent.CLICK, Button_CLICK); function Button_CLICK(e:MouseEvent):void{ background.play(); homeText.TextFormat(color "0x000000");}
I'm not sure if my code is just sloppy or if i'm completely going the wrong route here.
how can i get the value of a color from a variable. if i click the button, some rgb value should be stored in a variable and through some function i should get it. i wrote the function something like this:
------ on (press) { var colorful = new Color("_root.shapes"); colorful.setRGB(myVariable); } -------
I read the tutorial on this site about changing the color values of an object, or of a movie clip. My question is: How can I get the value of a color from a variable. If I click the button, some rgb value should be stored in a variable and through some function I should get it. I wrote the function something like this: on (press) { var colorful = new Color("_root.shapes"); colorful.setRGB(myVariable); } But it's not working.
I have two variables: var defaultMainHexidec:Number = 0xFFFFFF; var mainHexidec:Number;
If a value isn't assigned to mainHexidec I assign the default value as follows: mainHexidec = defaultMainHexidec; trace("mainHexidec = " + mainHexidec);
The trace returns the same value as the value returned when tracing the defualt value. But if I use mainHexidec as the fill for a rectangle, the color is black while the default value is white (or any other color). If I set the color using the default variable the fill appears correctly. If I set the number using the number traced in either defaultMainHexidec or mainHexidec (it traces the same number) the color is correct.
I have an XML file that is passing the color that is needed on a movie clip.I can make the color variable in the XML the actual HEX number and that works fine.Example:
The fill function that I made works as long as you only need one color. How do I make a variable that will store the color? flash keeps giving me an error for trying to do it the way I am doing it.
Code: fillit = function (d, e, f, g, color) { color2 = "0x"+color _root.lineStyle(1, 0x666666)
I have a text file that set's some color values I would like to use in my flash movie. basically its a configure file for movieclips rollovers(set's the colors)[code]...
Because the color of the background image in my application is very dark, and the Alpha is very low, when I hover my mouse over a checkbox, the text is scarcely visible. I've scoured the interwebz in vain for what property to set, either at design-time or in the MouseOver event for the checkbox and just can't figure out what property or setStyle property to alter to be able to control the color of the checkbox text when the mouse pointer is hovering over it.
I have an input text box (txtInput) and a dynamic text box (dynTxt). I want the dynamic text to stay black but highlight a segment of that text in yellow depending on certain characters.
I'm trying to change the colour of a movieclip.I want to send a variable from Javascript within the html that the swf will be embeded in.I'm not quite sure where to start with this but this is my code:
I have a text file that set's some color values I would like to use in my flash movie.bascially its a config file for movieclips rollovers(set's the colors)my textfile reads as follow
Code: textOut=0x3F6075&baseOut=0xFFFFFF&outLineOut=0xE19C14 My Flash is as follows:
I'm pulling text from an xml file into a dynamic text field and I need to highlight the text one paragraph at a time depending on where the timeline playhead is. I was thinking of doing this by changing the color of the text but I don't know how to do it inside the CDATA tags.At the moment one CDATA populates one text field.Another option is that there would be a movie clip behind the text that would jump to highlight a specific paragraph but then I would need to know how much vertical space each paragraph takes.
I'm trying to get the letters in a word (each letter is an individual text object) to cycle through three different colors when clicked. Right now, all they do is change from their original color, blue, to black when clicked. No further "cycling" occurs. I'm appending the code. The part of interest is (probably?) in what is presently (and inaccurately) the "traceTextEvent()" function/method. It starts around line 90 of the code.
I am trying to change the text color in a dynamic text field with xml.[code]but this creates a text field for you, which I dont need it created already have a dynamic text field with the var mybtninfo.What I have right now to get the text to show up in the field is:now only want to change the color of the text in the box thru XML.
I am working on a comboBox in flex. I am showing 5 items as item1, item2, item3, item4item5. Now i want to show first 2 items in red color and the last 3 items in green color. How to do this ? i need a solution asap.
I am building a project where I got XML text displayed on a textfield. How can I change a specific word's color through actionscript 3 instead of doing it on XML? I though of creating a String variable for my word and then using that variable in my textfield.text, it works but is it possible to set a color for that variable?
I am working on a comboBox in flex. I am showing 5 items as item1, item2, item3, item4, item5. Now i want to show first 2 items in red color and the last 3 items in green color.
i have a button, with instance name lightblue_color. I am assigning a color to its color field like this: lightblue_color.transform.colorTransform.color = 0x65ffff; then i am adding an eventlistener to the button like this: lightblue_color.addEventListener(MouseEvent.CLICK, ChangeColor); Then, in the function: public function ChangeColor(evnt:MouseEvent):void {trace(evnt.target.transform.colorTransform.color);} It prints 0. Why is that? Shouldn't it print 0x65ffff or do i need to do some type conversions?