AS3.0 加载进度条实例及详细步骤

上传人:飞*** 文档编号:2136566 上传时间:2017-07-20 格式:DOC 页数:8 大小:46.50KB
返回 下载 相关 举报
AS3.0 加载进度条实例及详细步骤_第1页
第1页 / 共8页
AS3.0 加载进度条实例及详细步骤_第2页
第2页 / 共8页
AS3.0 加载进度条实例及详细步骤_第3页
第3页 / 共8页
AS3.0 加载进度条实例及详细步骤_第4页
第4页 / 共8页
AS3.0 加载进度条实例及详细步骤_第5页
第5页 / 共8页
点击查看更多>>
资源描述

《AS3.0 加载进度条实例及详细步骤》由会员分享,可在线阅读,更多相关《AS3.0 加载进度条实例及详细步骤(8页珍藏版)》请在金锄头文库上搜索。

1、AS3.0 加载进度条实例 Flash 应用程序中经常会有许多体积较大的元素,当程序正在下载这些元素时,需要给用户一个正在加载的信息,这就是预载。在这个教程中,将学习如何制作一个 AS 3 的加载进度条。注意:这个制作需要 TweenMax ,所以需要 gs 类库。演示:1、准备加载的一个图像,如果图像在网上要知道网上图像的地址。2、新建 Flash 文件,设置属性:宽、高和图像的大小相同,背景为深色。3、用椭圆工具在舞台上画一个禁止笔触的 10 10 圆,填充颜色任意。4、将圆转换成影片剪辑,命名为 PreloaderCircle 设定注册点居中。5、设置类链接名 PreloaderCirc

2、le 。图 16、删除舞台上的PreloaderCircle影片。我们将会以代码形式创建。7、选中图层 1 的第一帧,打开动作面板输入代码: /导入 gs 类库 import gs.*; /创建一个容器 var holder:MovieClip = new MovieClip(); /创建一个空数组 var circles:Array = new Array(); /这个循环生成 5个圆并设定 x 坐标位置 for (var i:uint=0; i 20 & ! circles0.tweened) /Tween the circle TweenMax.to(circles0, 1, tint:

3、0xff8800, glowFilter:color:0xff8800, alpha:1, blurX:10, blurY:10); /If over 40% is loaded, tween the second circle if it hasnt been tweened yet. if (loadedPercentage 40 & ! circles1.tweened) /Tween the circle TweenMax.to(circles1, 1, tint:0xff8800, glowFilter:color:0xff8800, alpha:1, blurX:10, blurY

4、:10); /If over 60% is loaded, tween the third circle if it hasnt been tweened yet. if (loadedPercentage 60 & ! circles2.tweened) /Tween the circle TweenMax.to(circles2, 1, tint:0xff8800, glowFilter:color:0xff8800, alpha:1, blurX:10, blurY:10); /If over 80% is loaded, tween the fourth circle if it ha

5、snt been tweened yet. if (loadedPercentage 80 & ! circles3.tweened) /Tween the circle TweenMax.to(circles3, 1, tint:0xff8800, glowFilter:color:0xff8800, alpha:1, blurX:10, blurY:10); /If 100% is loaded, tween the fifth circle if it hasnnt been tweened yet. if (loadedPercentage = 100 & ! circles4.twe

6、ened) /Tween the circle and call the function circlesTweened() when the tween is complete (this is the last circle). TweenMax.to(circles4, 1, tint:0xff8800, glowFilter:color:0xff8800, alpha:1, blurX:10, blurY:10, onComplete: circlesTweened); /This function is called when the cirlces have been tweene

7、d (图像被加载) function circlesTweened():void /Loop through the circles for (var i = 0; i circles.length; i+) /Tween the circles to the left side of the stage. /Call the function circleLeft() when the tween is finished TweenMax.to(circlesi, 0.5, delay: i * 0.1, x: -200, alpha: 0, onComplete: circleLeft,

8、onCompleteParams: circlesi); /This function is called when a circle is animated to the left side. function circleLeft(circle:PreloaderCircle):void /把圆从舞台移除 holder.removeChild(circle); /Check if the circle is the last one (most right) if (circle = circles4) /把容器从舞台移除 removeChild(holder); /从装货机获取位图 va

9、r bm:Bitmap = (Bitmap)(loader.content); /创建一个影片剪辑容器,把位图加入影片剪辑容器 var bmHolder:MovieClip = new MovieClip(); bmHolder.addChild(bm); /把位图容器加入舞台 addChild(bmHolder); /Animate the bitmap holder TweenMax.from(bmHolder, 1, alpha: 0); 复制代码 8、完成,测试影片。-我有一段 AS3.0的下载进度条脚本,制作过程:场景一:输入以下脚本:点选 AS 层的第 1帧填加语句:SWF(bac

10、kgroundColor=0x0)stop();stage.showDefaultContextMenu=false;var W=stage.stageWidth;var H=stage.stageHeight;var Load:MovieClip=new MovieClip();addChildAt(Load,1);var a_txt:TextField=new TextField();a_txt.autoSize=TextFieldAutoSize.CENTER;a_txt.text=AS3.0 Loading.;a_txt.textColor=0xff0000;a_txt.selecta

11、ble=false;a_txt.x=W/2-a_txt.width/2;a_txt.y=H/2-a_txt.height/2;Load.addChild(a_txt);var sp:Sprite=new Sprite();sp.graphics.lineStyle(1,0x0000ff,1);sp.graphics.beginFill(0x00ff00);sp.graphics.drawRect(0,0,200,10);sp.graphics.endFill();sp.x=W/2-sp.width/2;sp.y=a_txt.y+a_txt.height+5;Load.addChild(sp);

12、var stg:Sprite=new Sprite();stg.graphics.lineStyle(1,0x000000,.5);stg.graphics.beginGradientFill(GradientType.LINEAR,0xff0000,0xffff00,50,100,120,255);stg.graphics.drawRect(0,0,200,10);stg.graphics.endFill();stg.x=W/2-stg.width/2;stg.y=a_txt.y+a_txt.height+5;Load.addChild(stg);var xin:MovieClip=new

13、Xin();loaderInfo.addEventListener(ProgressEvent.PROGRESS,loading);loaderInfo.addEventListener(Event.COMPLETE,loaded);function loading(event: ProgressEvent) var loadpre:int=event.bytesLoaded/event.bytesTotal*100;a_txt.text=动画载入中 .+loadpre+ %;stg.scaleX=loadpre/100;addChildAt(xin,0);function loaded(event:Event) a_txt.tex

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 研究报告 > 综合/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号