当前位置: 首页 > 图文教程 > Flash动画 > ActionScript > AS3.0实例:鼠标感应发光的文字效果

ActionScript
ActionScript3教程:语句实例
ActionScipt技巧和开发中会遇到的问题
Flash as3.0教程:弹性小球
flash as简单制作飘雪动画
Flash AS 教程:交互动画
Flash ActionScript 3.0教程:学习Dot类
Flash AS 教程:子类化显示对象
Flash AS 教程:动画事件
Flash AS 教程:创建文档类(Document class)
Flash AS 教程:帧循环
Flash AS 教程:类和面向对象编程
Flash AS 教程:构造函数(Constructor)
Flex程序开发心得小结
Flash游戏开发教程:第一节
FLASH中的元件能在Flex中完美使用
关于XML在FLASH中的应用
Flash AS教程:decorator Pattern
Flash AS实例教程:简单的loading
Flash教程:彻底学习RadioButton组件
Flash AS教程:复制粘贴类

ActionScript 中的 AS3.0实例:鼠标感应发光的文字效果


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2010-03-20   浏览: 231 ::
收藏到网摘: n/a

 这是一个非常简单的教程,将学习用发光滤镜使对象产生发光的效果。注意:这个实例需要 TweenMax 类,请把附件中的gs类库保存在fla同一目录下。

AS3.0发光的文字效果实例

这是一个非常简单的教程,将学习用发光滤镜使对象产生发光的效果。

注意:这个实例需要 TweenMax 类,请把附件中的gs类库保存在fla同一目录下。

演示:


1、新建Flash文件,设置属性:宽高根据舞台上的影片剪辑多少设定,我这里为 550 × 200 ,背景黑色。图1:
sshot-1.png
2、选文本工具,在舞台上输入一些静态的本文。根据需要选择字型和字的大小。颜色选你喜欢的。图2:
sshot-2.png
3、选菜单=>修改=>分离,把文字打散。图3:
sshot-3.png
4、单选每一个字,右键单击转换为影片剪辑。命名根据你的需要,设定注册点为居中。图4:
sshot-4.png
全部完成后库如图5:
sshot-5.png
5、添加as层,选中第一帧,输入下列代码:


//Import tweenmax

import gs.*;



//Loop through all the letters in the stage

for (var i=0; i < numChildren; i++) {



        //Get a letter (movie clip) from the stage

        var mc:* = getChildAt(i);



        //Add an MOUSE_OVER listener for the letter

        mc.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);



        //Tween the letter to have a white glow

        TweenMax.to(mc, 0.2 , {glowFilter:{color:0xffffff, alpha:1, blurX:10, blurY:10}});

}



//This function is called when the mouse is over an letter

function mouseOverHandler(e:Event):void {



        //Save the letter to a local variable

        var letter:MovieClip = e.target as MovieClip;



        //Animate the letter.

        //We call the function scaleBack() when the tween is finished

        TweenMax.to(letter, 0.8 , {scaleX: -1, glowFilter:{color:0xff8800, blurX:20, blurY:20}, onComplete: scaleBack, onCompleteParams:[letter]});

}



//This function is called when a letter’s scaleX is -1

function scaleBack(letter:MovieClip):void {



        //Animate the letter back to original state

        TweenMax.to(letter, 0.2 , {scaleX: 1, glowFilter:{color:0xffffff, blurX:10, blurY:10}});

}
6、完工,测试你的电影。

7、延伸:你可以把舞台上的影片剪辑更换为任何元素,任何颜色的光效果。