当前位置: 首页 > 图文教程 > Flash动画 > Flash动画制作 > FLASH MX2004体验二:定制组件外观

Flash动画制作
Flash卡通景物绘制
鼠绘偏写实人物
鼠绘--柱顶红的画法
FLASH实现滚动条+网页书签效果
Flash MX中Button Object的用法
as入门之数学函数--弧度
as入门之数学函数--Math类
闪动的变色圆盘
组件封装为mxp文件的方法
判断数字大小
Flash 缓存问题的解决
Flash MX pro 2004 新特性之Flash Lite
在Flah MX2004的ListBox中应用HTML
Flash MX 2004中的XML应用之原理篇
Flash MX 2004视频教程超速入门系列(1)
Flash MX 2004视频教程超速入门系列(2)
Flash MX 2004视频教程超速入门系列(3)
Flash MX 2004视频教程超速入门系列(4)
Flash MX 2004视频教程超速入门系列(5)
Flash MX 2004视频教程超速入门系列(6)

Flash动画制作 中的 FLASH MX2004体验二:定制组件外观


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-22   浏览: 74 ::
收藏到网摘: n/a

MX2004自带的组件比MX漂亮了很多, 但有时候为了让组件的外观和整个页面的样式相统一, 必须重新改变组件的外观, 比如组件标签的字体和颜色, 组件的背景颜色等等. 这个FlashMX自身是做不到的.

       改变组件外观有三种方法: Use the Styles API(使用样式API), Apply a theme(应用一个主题名), 和Modify or replace a component's skins(修改或替换组皮肤). 这里着重说明第一种方法, Use the Styles API(application programming interface). 我们可以利用Styles API 提供的属性和方法( setStyle()和getStyle())来改变组件的颜色和文本格式.

       其中使用Styles又有四种方法:

      1.Set styles on a component instance. (对一个组件实例设置样式)
      2.Use the _global style declaration that sets styles for all components in a document.(使用全局样式声明对文档的所有组件设置样式)
      3.Create custom style declarations and apply them to specific component instances.(创建自定义样式声明并应用到指定的组件实例)
      4.Create default class style declarations.(为组件类别创建样式声明)
     
      下面对每一种方法进行详解.

      
      Set styles on a component instance (对一个组件实例设置样式).

       从components面板拖个Button 组件到场景(也可以用其它组件),并命名为”myBtn”:

       快捷键”F9”打开Action面板,在时间线上写Action:

myBtn.setStyle("themeColor", "0x00CCFF");
myBtn.setStyle("fontFamily", "Verdana");
myBtn.setStyle("fontSize", "10");
myBtn.setStyle("fontWeight", "bold");
myBtn.setStyle("color", "0x990000");

       Ctrl+Enter 预览效果,组件样式是不是改变了?下面是默认的样式和刚才自定义样式的效果对比图:

      Use the _global style declaration that sets styles for all components in a document.(使用全局样式声明对文档的所有组件设置样式)
        

       FlashMX2004的_global对象的Style属性可以做到这一点:  从components面板拖n 个组件到场景,这里我用的是Button,CheckBox和RadioButton 三个组件,也不要给组件命名,直接在时间线上写Action:
        
  

_global.style.setStyle("themeColor", "0x00CCFF");
_global.style.setStyle("fontFamily", "Verdana");
_global.style.setStyle("fontSize", "10");
_global.style.setStyle("fontWeight", "bold");
_global.style.setStyle("color", "0x990000");

      Ctrl+Enter 预览效果.下面是这三个组件的前后效果对比图:

      &nbs