Solved

runtime CSS change in flex

Posted on 2009-04-14
3
346 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

Question has a verified solution.

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

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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.
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…

730 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