Flash Vista - Home
Newest Cool Site
The Two Tales
Site info | Archive
Main Navigation
Home
New Links
Top Rated
Most Popular
Cool Sites
Search

Flash Tutorials
Flash Resources
Flash News
Flash Templates
Flash Intro Templates
Website Templates
Flash Games
Flash Books
FlashVista Polls
Sitemap


Random Link
English
Moon
Site info | Get another
FlashVista
Login
Register
Subscribe

Add Link
Modify Link
Favorites
Suggest Category

Advertise with us
Support us
Credits / Thanks
Contact

Flash Templates:

More Templates ...

Mailing List
User

Password



Register
Forgot password?
Partner websites
Flash Templates
Flash Components
Free Hit Counter
Free Seo Tools
Free Tutorials
Free Video Tutorials
Forum signatures
Other Resources
Suggest
Suggest this site to a friend


Mailing List
Status: Not logged in

English English German French Spanish Italian Portuguese Russian Polish Finnish Dutch Swedish Thai Romanian Traditional Chinese Simplified Chinese
SearchNot logged in
Keyword: Search for: Advanced Search


Using global CSS in your cfform


NEW Flash Tutorials in Video Format - Powered by LearnFlash.com: 45 minutes of flash tutorials now available in streaming format or download. Topics Include flash for beginners, text effects, actionscripting, audio/video, flash 8 and more.


Printer version



By As Fusion
http://www.asfusion.com/blog/


The other day someone asked in the comments about a way to use CSS classes instead of adding inline styles in each control. One of the problems is that using inline code consume a lot of Kb and it's good to save size as much as possible because a form only allows the use of 32Kb (or 64Kb depending on who you ask :)). Right now, it is not possible to include an external CSS file with all our styles. I wish ( and it's on top of my list) that the next update will allow it :)
For now, and because we have the onLoad event in the CF Updater 7.01 we can set up some global styles when the form loads and save some Kb to spend in other places.The idea of this technique is to set the properties of the components that we want to change when the form loads one by one. Note that any inline style will overwrite the global style for that control. Also, for styles that are inheritable (themeColor for example), you can use the style property of the form tag. A list of controls with their properties can be found on the Flex docs. In this example I'm just showing a few of them.

The looks like this

cfform name="myform" height="400" width="280" format="Flash" onload="formOnLoad()">

function formOnLoad()
{
// Do anything that you need to do in the onload Event

// call the function that is in charge of applying the styles

applyStyles();
}
function applyStyles()
{
_global.styles.CheckBox.setStyle("fillColors", [0x006699, 0xffffff]);
_global.styles.RadioButton.setStyle("fillColors", [0x006699, 0xffffff]);
_global.styles.Form.setStyle("color", 0x000000);
_global.styles.Button.setStyle("borderThickness", 1);
_global.styles.Panel.setStyle("backgroundColor", 0xE5F0F9);
_global.styles.Panel.setStyle("color", 0xffffff);
_global.styles.Panel.setStyle("headerColors", [0x277DC6,0x50ABF7]);
_global.styles.HBox.setStyle("backgroundColor", 0x006699);
_global.styles.HBox.setStyle("marginTop", 10);
_global.styles.HBox.setStyle("marginBottom", 10);
_global.styles.HBox.setStyle("marginLeft", 10);
_global.styles.Accordion.setStyle("fillColors", [0x277DC6,0x50ABF7]);
_global.styles.Accordion.setStyle("selectedFillColors", [0xff6600,0xffcc00]);
_global.styles.Accordion.setStyle("themeColor", 0x0066cc);
_global.styles.Accordion.setStyle("color", 0x0ffffff);
_global.styles.TextArea.setStyle("fontSize",14);
_global.styles.TextInput.setStyle("fontSize",9);

}








Some large text


Check Box

Radio Buttons













Live Example
Download the source

Read the complete article here

(Added: 10-28-2005, Hits: 0, Rating: 0.00, Votes: 0, Reviews: 0)
Add to Favorites Suggest to a Friend

Reviews: (0)


Add Review
Please note:
We review EVERY comment before it appears on the site, so please dont waste your time by posting spam links :)
No URLs allowed, no HTML please.

If you register or login first, your review will contain your nickname


Rate It



Excellent!
Very Good
Good
Fair
Poor