Solved

runtime CSS change in flex

Posted on 2009-04-14
3
340 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Exception reading an iframe content from chrome console 12 973
multi page pdf 4 69
Help on HTML 1 64
Reason for High TTFB 1 34
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Foolproof security solutions has become one of the key necessities of every e-commerce or Internet banking website. If you too own an online shopping site then its vital for you to equip your web portal with customer security features that can allow…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…

758 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

19 Experts available now in Live!

Get 1:1 Help Now