Solved

runtime CSS change in flex

Posted on 2009-04-14
3
341 Views
Last Modified: 2012-05-06
Hi All,

I am working in Flex. I want to set style bold / italic / underline depending upon the selection of a buttons.
I am using the following to set the font style/weight but it is not working.

I want to set the bold and italic formatting dynamically upon clicking BOLD or ITALIC button given in the application.

Please help me with this.

Thanks
var txt:TextInput = new TextInput();

txt.setStyle("font-weight", "bold");

txt.setStyle("font-style", "italic");

Open in new window

0
Comment
Question by:jchittoda1
3 Comments
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24141203
what version of flex are you on ?
0
 
LVL 5

Accepted Solution

by:
Fuzzy_Logic_ earned 125 total points
ID: 24141667
try this instead:


var txt:TextInput = new TextInput();

txt.setStyle("fontWeight", "bold");

txt.setStyle("fontStyle", "italic");

Open in new window

0
 
LVL 2

Expert Comment

by:hockeyragazzo
ID: 24142204
Surprisingly (and annoyingly) CSS in Flex uses different style property names than are used in Flex. So, as Fuzzy Logic pointed out, while inside a <Style> tag you need to say "font-weight," when you're setting the style dynamically in Actionscript, you need to use the Flex-standard names for the properties: "fontWeight."

Another example:

background-color = backgroundColor

The full list of component properties can be found in the Flex docs from Adobe. In particular, here it is for the TextInput component:

http://livedocs.adobe.com/flex/3/langref/mx/controls/TextInput.html#styleSummary

As you already know, you say txt.setStyle("nameOfStyle", "propertyValue"); or you can get the style like this:

txt.getStyle("nameOfStyle");

Or you can get more complex:

txt1.setStyle("nameOfStyle", txt2.getStyle("nameOfStyle"));
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (May 2015) This web page has appeared at Google.  It's definitely worth considering! https://www.google.com/about/careers/students/guide-to-technical-development.html How to Know You are Making a Difference at EE In August, 2013, one …
It’s a strangely common occurrence that when you send someone their login details for a system, they can’t get in. This article will help you understand why it happens, and what you can do about it.
This video teaches users how to migrate an existing Wordpress website to a new domain.
Learn how to set-up custom confirmation messages to users who complete your Wufoo form. Include inputs from fields in your form, webpage redirects, and more with Wufoo’s confirmation options.

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now