更改MX 2004 Halo组件上的属性

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.

关于Flash MX 2004组件和Halo主题,我最常被问到的问题之一是如何从标准花哨的颜色中全局更改List组件等中“翻转”的颜色。 在以下示例(我尚未更改所有属性)中,只需在Flash MX 2004中创建一个新的Flash文档,将以下代码添加到默认层的第一帧中,然后将“列表和文本区域”组件的一个实例拖到舞台和电影预览。

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.

代码很简单,在此示例中,它随机地将'themeColor'和'background'颜色更改为随机值,将'fontSize'和'fontWeight'设置为更有用,并随机更改字体颜色。 使用setInterval(),每秒更新一次RandomizeStyles()函数,以显示实际的随机性。

更改MX 2004 Halo组件上的属性

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.

注意:在您的项目的真实示例中,您显然会将'themeColor'和其他属性从随机值更改为适合您站点的调色板。

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);

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);

翻译自: https://www.sitepoint.com/changing-attributes-on-mx-2004-halo-components/