Flash制作旋转小星星动画实例教程(代码实现)
具体制作过程如下
1、新建一个fla文件,宽400高400,帧频默认,背景颜色黑色,保存。
2、选择多边形工具,设置为5边,星形。在舞台上画一个任意颜色、大小的星。
3、在选取状态下,右键转换为影片剪辑,全对齐,命名为Star,删除舞台上的星。
4、按Ctrl+L组合键,打开库面板,右键单击Star影片剪辑,选择“属性”打开元件属性面板,勾选ActionScript选项,这样就使影片剪辑与Star类进行了绑定。如图
5、狼蚁网站SEO优化开始编写Star类的代码,新建一个ActionScript文件。
输入狼蚁网站SEO优化的代码
package {
import Flash.display.MovieClip;
import flash.geom.ColorTransform;
import flash.events.;
public class Star extends MovieClip {
private var starColor:uint;
private var starRotation:Number;
public function Star () {
//Calculate a random color
this.starColor = Math.random() 0xffffff;
// Get Aess to the ColorTransform instance associated with star.
var colorInfo:ColorTransform = this.transform.colorTransform;
// Set the color of the ColorTransform object.
colorInfo.color = this.starColor;
// apply the color to the star
this.transform.colorTransform = colorInfo;
//Assign a random alpha for the star
this.alpha = Math.random();
//Assign a random rotation speed
this.starRotation = Math.random() 10 - 5;
//Assign a random scale
this.scaleX = Math.random();
this.scaleY = this.scaleX;
//Add ENTER_FRAME where we do the animation
addEventListener(Event.ENTER_FRAME, rotateStar);
}
//This function is responsible for the rotation of the star
private function rotateStar(e:Event):void {
this.rotation += this.starRotation;
}
}
}
6、保存在fla同一目录下,保存名为Star.as。注意这一步非常重要,一定要同fla主文件保存在相同的目录下,如果保存在其它的目录下,要指明路径。初学者在测试时往往出现找不到类的错误提示,问题都在这里。
7、返回到fla,在第1层的第一帧输入代码
for (var i = 0; i < 100; i++) {
var star:Star = new Star();
star.x = stage.stageWidth Math.random();
star.y = stage.stageHeight Math.random();
addChild (star);
}
8、好了,所有的工作都已经完成,测试你的影片。
平面设计师
- 免费平面设计网站 免费平面设计绘图软件
- 平面设计基础知识题库
- 平面设计基础学包括哪些
- ui设计师工资一般多少 北京ui设计师工资一般多少
- 平面设计技巧方法 平面设计技巧总结
- 哪里的平面设计培训班比较好 哪家平面培训设计
- 哪些人不适合学平面设计 平面设计师工资一般多
- 女生学习平面设计还有其独特的优势
- 平面设计大学专业叫什么 平面设计大学专业叫什
- ui就业前景和工资待遇 ui就业前景和工资待遇怎么
- 平面设计ps入门教程 平面设计photoshop 基本操作方
- 免费学平面设计教程 平面设计免费教程网站
- 平面设计就业方向有哪些 平面设计专业就业前景
- 女生学什么设计前景好 女孩学什么设计好赚钱
- 什么人适合学平面设计 学平面设计后悔死了
- 平面设计内容有哪些 平面设计内容包括什么