?
Solved

runtime CSS change in flex

Posted on 2009-04-14
3
Medium Priority
?
349 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 500 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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
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.
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

771 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