Blog Post RSS ?

Blogs » Flash » Changing Attributes on MX 2004 Halo Components
 

Changing Attributes on MX 2004 Halo Components

by sgrosvenor

One of the most often questions I get asked regarding Flash MX 2004 components and the Halo theme, is how to globally alter the color of the ‘Rollover’ in the List Component etc from the standard garish colors. In the following examples (I haven’t changed all the attributes), just create a new Flash document in Flash MX 2004, add the following code to the first frame of the default layer and drag an instance of the List and Text Area component to the stage and preview the movie.

The code is simple, and in this example, it randomly changes the ‘themeColor’, background’ colors to a random value, sets the ‘fontSize’ and ‘fontWeight’ to something more usable and randomly changes the font color. Using setInterval() the RandomizeStyles() function is updated every second to show the randomness in action.

Note: In a real world example for your projects, you would obviously change the ‘themeColor’ and other attributes from a random value to a pallete that suits your site.

function RandomizeStyles() { _global.style.setStyle("themeColor", Math.round(Math.random()*0xF6f6f6)); _global.style.setStyle("backgroundColor", Math.round(Math.random()*0xF6f6f6)); _global.style.setStyle("fontSize", 11); _global.style.setStyle("fontWeight", "bold"); _global.style.setStyle("color", Math.round(Math.random()*0xF6f6f6)); } RandomizeStyles(); setInterval(RandomizeStyles, 1000);

This post has one response so far

  1. wrong method

     

Sponsored Links

Leave a response

You are not logged in, log in with your SitePoint Forum username and password.

-OR- Post Anonymously

* Make sure any code samples are escaped (i.e. ‘<b>’ becomes ‘&lt;b&gt;’).

If not logged in, your comments will be placed in a moderation queue. This means your comment may not appear until one of our moderators approves it.

SitePoint Marketplace

Buy and sell Websites, templates, domain names, hosting, graphics and more.