Flash AS3制作数字落下的动画特效
平面设计 2021-07-03 14:35www.168986.cn平面设计培训
本教程教大家如何利用Flash AS3制作数字落下的动画特效,制作出来的效果非常漂亮,教程属于基础入门教程,适合新手学习,转发过来,希望大家喜欢。
我们先来看看数字落下的动画特效演示
制作步骤如下
1、新建Flash文件,属性设置 400 × 400 ,背景黑色,帧频30。图1
2、选文本工具,创建一个动态的文本。输入数字 1。
3、在属性面板中为实例命名 " myText" 。设定字号为 15 ,颜色#00ff00。图2
4、按字符嵌入按钮,嵌入字符集。设置如图3
5、把本文转换成 影片剪辑 。命名为 " numberInsideMC" 。将注册点设定为左上角。图4
6、在属性面板中为实例命名 " numberInside" 。图5
7、把 " numberInsideMC" 转换成影片剪辑。 提供新的影片剪辑名字 " myNumberMC" 。将注册点设定为左上角。图6
8、按Ctrl+L组合键,打开库面板,右键单击 " myNumberMC" 选属性(CS4、CS3为链接)作类的绑定,链接名为 " BitNumber" 。图7
9、新建图层,改名 as 层,选中第1帧,输入下列代码
复制代码
代码如下://This array will contain all the numbers seen on stage
var numbers:Array = new Array();
//We want 8 rows
for (var i=0; i < 8; i++) {
//We want 21 columns
for (var j=0; j < 21; j++) {
//Create a new BitNumber
var myNumber:BitNumber = new BitNumber();
//Assign a starting position
myNumber.x = myNumber.width j;
myNumber.y = myNumber.height i;
//Give it a random speed (2-7 pixels per frame)
myNumber.speedY = Math.random() 5 + 2;
//Add the number to the stage
addChild (myNumber);
//Add the number to the array
numbers.push (myNumber);
}
}
//Add ENTER_FRAME so we can animate the numbers (move them down)
addEventListener (Event.ENTER_FRAME, enterFrameHandler);
/
This function is repsonsible for moving the numbers down the stage.
The alpha animation is done inside of the myNumberMC movieclip.
/
function enterFrameHandler (e:Event):void {
//Loop through the numbers
for (var i = 0; i < numbers.length; i++) {
//Update the y position
numbers[i].y += numbers[i].speedY;
//If the BitNumber is below the stage, move it up again
if (numbers[i].y > stage.stageHeight) {
numbers[i].y = 0;
}
}
}
var numbers:Array = new Array();
//We want 8 rows
for (var i=0; i < 8; i++) {
//We want 21 columns
for (var j=0; j < 21; j++) {
//Create a new BitNumber
var myNumber:BitNumber = new BitNumber();
//Assign a starting position
myNumber.x = myNumber.width j;
myNumber.y = myNumber.height i;
//Give it a random speed (2-7 pixels per frame)
myNumber.speedY = Math.random() 5 + 2;
//Add the number to the stage
addChild (myNumber);
//Add the number to the array
numbers.push (myNumber);
}
}
//Add ENTER_FRAME so we can animate the numbers (move them down)
addEventListener (Event.ENTER_FRAME, enterFrameHandler);
/
This function is repsonsible for moving the numbers down the stage.
The alpha animation is done inside of the myNumberMC movieclip.
/
function enterFrameHandler (e:Event):void {
//Loop through the numbers
for (var i = 0; i < numbers.length; i++) {
//Update the y position
numbers[i].y += numbers[i].speedY;
//If the BitNumber is below the stage, move it up again
if (numbers[i].y > stage.stageHeight) {
numbers[i].y = 0;
}
}
}
10、双击舞台上的 myNumberMC 影片剪辑,进入myNumberMC编辑状态,添加as图层,选中第1帧,输入代码
复制代码
代码如下://This variable tells us should we increase the alpha
var increaseAlpha:Boolean;
//We want the number to be invisible at the beginning
numberInside.alpha = 0;
//Calculate a random timer delay (how often we increase the alpha)
var timerDelay:Number = Math.random() 4000 + 2000;
//Create and start a timer
var timer:Timer = new Timer(timerDelay, 0);
timer.addEventListener (TimerEvent.TIMER, timerHandler);
timer.start ();
//Add ENTER_FRAME so we can animate the alpha change
addEventListener (Event.ENTER_FRAME, enterFrameHandler);
/
Timer calls this function.
Timer delay defines how often this is called.
/
function timerHandler (e:Event):void {
//Update the increaseAlpha value
increaseAlpha = true;
//Calculate a random number (0 or 1)
var newNumber:int = Math.floor(Math.random() 2);
//If the random number is 1, we insert "1" into the text box
if (newNumber == 1) {
numberInside.myText.text = "1";
}
//Else we insert "0" into the text box
else {
numberInside.myText.text = "0";
}
}
//This function animates the alpha
function enterFrameHandler (e:Event):void {
//Increase the alpha if increaseAlpha is true
if (increaseAlpha == true) {
numberInside.alpha += 0.02;
}
//Else we want to decrease the alpha
else {
numberInside.alpha -= 0.02;
}
//We don’t want the alpha to be over one, so we assign increaseAlpha to be false
if (numberInside.alpha > 1) {
increaseAlpha = false;
}
//If the alpha is negative, set it to zero
if(numberInside.alpha < 0) {
numberInside.alpha = 0;
}
}
var increaseAlpha:Boolean;
//We want the number to be invisible at the beginning
numberInside.alpha = 0;
//Calculate a random timer delay (how often we increase the alpha)
var timerDelay:Number = Math.random() 4000 + 2000;
//Create and start a timer
var timer:Timer = new Timer(timerDelay, 0);
timer.addEventListener (TimerEvent.TIMER, timerHandler);
timer.start ();
//Add ENTER_FRAME so we can animate the alpha change
addEventListener (Event.ENTER_FRAME, enterFrameHandler);
/
Timer calls this function.
Timer delay defines how often this is called.
/
function timerHandler (e:Event):void {
//Update the increaseAlpha value
increaseAlpha = true;
//Calculate a random number (0 or 1)
var newNumber:int = Math.floor(Math.random() 2);
//If the random number is 1, we insert "1" into the text box
if (newNumber == 1) {
numberInside.myText.text = "1";
}
//Else we insert "0" into the text box
else {
numberInside.myText.text = "0";
}
}
//This function animates the alpha
function enterFrameHandler (e:Event):void {
//Increase the alpha if increaseAlpha is true
if (increaseAlpha == true) {
numberInside.alpha += 0.02;
}
//Else we want to decrease the alpha
else {
numberInside.alpha -= 0.02;
}
//We don’t want the alpha to be over one, so we assign increaseAlpha to be false
if (numberInside.alpha > 1) {
increaseAlpha = false;
}
//If the alpha is negative, set it to zero
if(numberInside.alpha < 0) {
numberInside.alpha = 0;
}
}
11、切换回场景1,把 myNumberMC 影片剪辑从舞台上删除。
12、完工,测试你的影片。
教程结束,以上就是利用Flash AS3制作数字落下的动画特效过程,方法很简单吧,喜欢的朋友可以尝试自己制作一个!感谢大家的观看本教程!
平面设计师
- 平面设计图怎么画 小学生画平面图
- 平面设计内容怎么写 平面设计的求职意向怎么写
- 平面设计图手绘 平面设计图手绘家具
- 平面设计多久能出师 平面设计要多久
- 女生做ui设计师有多累 女生为什么学ui的人很惨
- 哪里有学平面设计的学校 想学平面设计去哪里学
- 初学平面设计用哪个软件 平面设计初学者必备的
- 0基础学平面设计要多久 0基础自学平面设计
- 平面设计手绘培训 平面设计师培训班学费多少钱
- ui工作好找工作吗 ui好不好找工作
- 女生学室内设计吃香吗
- ps平面设计自学教程 平面设计ps入门教程
- 平面设计基础知识大全 平面设计基本常识
- 平面设计基础教学视频 平面设计教学零基础入门
- 平面设计基础教学 平面设计基础教学平时作业
- ui设计主要是学什么 ui设计一般是学什么