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

Flash动画制作
使用SetMask脚本制作沿路径运动的遮罩实例
Flash MX 2004 ActionScript图文教程(一)
拖出你的精彩:Flash MX课件中的拖动
Flash实例教程:鱼戏莲叶间
Flash MX pro的历史面板(一)
Flash MX pro的历史面板(二)
Flash MX pro的历史面板(三)
Flash常见问题解答集锦(1)
Flash MX行为功能初体验:相册的制作
Flash MX04文字特效:残影动画(图)
Flash游戏制作常用代码解析(图)
在Flash中巧妙替换字体
用FlashMX制作拖动悬浮窗口
让Flash课件在VCD上播放
PowerPoint中插入Flash动画的方法
使用Flash mx制作旋转的时钟效果
用Flash制作动感火焰字
Flash Mx使用技巧十二则
用Flash MX制作新年贺卡
Flash那样动感十足制作PPT按钮跟我来

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-22   浏览: 34 ::
收藏到网摘: 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