Different “backgroundColor” for ToolTip’s in Flex.

Few days back one of the reader commented whether there is a way to change the “backgroundColor” of the ToolTips for different Controls dynamically in Flex. And my answer was “yes” and solution is here in this post.

What we got to do to achieve this ??

First we got to know about the Class StyleManager.

Basic information About the Class.

The StyleManager class lets you access class selectors and type selectors in ActionScript. It also lets you apply inheritable and noninheritable properties globally. Using the StyleManager, you can define new CSS style declarations and apply them to controls in your Flex applications.

[ These lines are from the HELP in Flex builder as they are the BEST, for any further information refer HELP from Flex Builder.ย  ๐Ÿ™‚ ]

Then Setting Styles with the StyleManager.

To set a value using the StyleManager, use the following syntax:

mx.styles.StyleManager.getStyleDeclaration(style_name).

setStyle(“property“, value);

Example ::

For Example here i want the backgroundColor of the ToolTip to change dynamically. So the line of code would be like below.

StyleManager.getStyleDeclaration(“ToolTip”).

setStyle(“backgroundColor”,”red”);

This can be called at any point where you would prefer to change , for example i can call this line on rollOver of a Button or a Control.[ Just keep in mind that this will reflect all the Visible controls in the App so care should be taken to reset the defaults when necessary ]

Now Enjoy this Demo here.

Comments are welcome. ๐Ÿ™‚ , Enjoy the Post.

Advertisements

3 Responses to Different “backgroundColor” for ToolTip’s in Flex.

  1. mamtha says:

    Thanks for the custom tooltip background. Is there a way skin tree control? Can I skin the folder Icon with an image? Not adding the icon but replacing the folder icon with an image thats like a button.

    Thanks
    mamtha

  2. kumargandhi says:

    yes you can do that !.

    regards,
    kumar.

  3. bhargavi says:

    when tree node is clicked i want that particular node background color should be changed

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: