`
hereson
  • 浏览: 1428076 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

AS3 Loading的制作方法

阅读更多

AS2的时候做LOADING有很多种方法,做起来也得心应手
可是到AS3的时候做LOADING的时候却无从下手,抓瞎了几天
因为在AS3中引入了一个全新的类LoaderInfo,这个类可作用
于任何的可显示对象(display object),这个对象里包含了加
载过程检测、加载地址、加载对象的内容、加载对象总字节数(和
加载过程中的字节数)、加载对象的宽度高度等等非常多的内容
有2种方式可以访问LoaderInfo对象:
1)访问flash.display.Loader对象的contentLoaderInfo属性;
2)任何一个可显示对象(display object)都有loaderInfo属性;

注意:每个SWF文档的主类的实例有loaderInfo属性,每个Loader有loaderInfo属性,同时它有一个contentLoaderInfo属性,通过这个属性你可以访问到Loaded对象的loaderInfo。

下面还来例子示范。
首先来一个loading外部文件的例子:

CODE:
var request:URLRequest = new URLRequest(”flashrek.swf”);
var loader:Loader = new Loader();

loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, loadProgress);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);

function loadProgress(event:ProgressEvent):void {
var percentLoaded:Number = event.bytesLoaded/event.bytesTotal;
percentLoaded = Math.round(percentLoaded * 100);
trace(”Loading: ”+percentLoaded+”%”);
}
function loadComplete(event:Event):void {
trace(”Complete”);
}

loader.load(request);
addChild(loader);

这里要注意loader的load方法只接受URLRequest对象作为参数;另外就是ProgressEvent类,比较简单,看帮助就好了。

这里只是LOAD外部对象,如何做自身LOADING还要再研究研究,等有了答案再更新。

更新自身Loading

code:

stop();
import flash.display.LoaderInfo;
import flash.events.ProgressEvent;
import flash.text.TextField;
var loadText:TextField=new TextField();
addChild(loadText);
this.loaderInfo.addEventListener(ProgressEvent.PROGRESS,myloadmovie);
this.loaderInfo.addEventListener(Event.COMPLETE,myover);
function myloadmovie(event:ProgressEvent):void {
var hl:Number=event.bytesLoaded/event.bytesTotal;
var n:Number=Math.round(hl*100);
loadText.text=n+”%”;
}
function myover (event:Event):void {
this.loaderInfo.removeEventListener(ProgressEvent.PROGRESS,myloadmovie);
nextFrame();
}

下面是另一种自身loading的方法

CODE:
stop();
import flash.display.LoaderInfo;
import flash.events.ProgressEvent;
import flash.text.TextField;
var loadText:TextField=new TextField();
loadText.x=220;
loadText.y=200;
addChild(loadText);
myload.addEventListener(Event.ENTER_FRAME,onEnterFramee);
function onEnterFramee (event:Event) {
if (framesLoaded==totalFrames) {
trace(1);
myload.removeEventListener(Event.ENTER_FRAME,onEnterFramee);
nextFrame();
}
else {
var percent:Number=root.loaderInfo.bytesLoaded/root.loaderInfo.bytesTotal;
var m:Number=Math.round(percent*100);
myload.gotoAndStop(m);
loadText.text=m+”%”;
}
} //myload为场景中预设的loading动画的MC名字

分享到:
评论

相关推荐

    Flash CS3 AS3.0影片Loading制作

    Flash CS3 AS3.0影片Loading制作

    Flash Loading源程序

    Flash Loading ANCTIONScript 源程序

    javascript制作loading动画效果 loading效果

    //wraperid : 显示loding图片的容器元素//ms:表示loding图标显示的时长,毫秒//envent:表示出发事件的事件源对象,用于获得出发事件的对象//callback:表示动画结束后执行的回掉方法//stop()方法表示在回掉方法...

    Flash Loading加载动画样式集源文件.rar

    Flash Loading加载动画样式集源文件,6种不同的用于制作Flash加载动画时候的动画效果集,在这些动画剪辑的基础上,再加上as脚本,就可实现一款漂亮专业的Flash Loading动画。

    静态图片人脸识别工具类

    .asBitmap() .centerCrop() .placeholder(R.drawable.ic_iamge_zhanwei) .into(new SimpleTarget() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> ...

    网页制作完全手册

    Conditional comments are processed during the downloading and parsing phase, so only the content that is targeted for the browser loading the Web page is actually downloaded. Conditional comments can...

    将图片制作成内存对象数据集

    将图片制作成内存对象数据集 import tensorflow as tf import os from matplotlib import pyplot as plt import numpy as np from sklearn.utils import shuffle def load_sample(sample_dir): '''递归读取文件。...

    DELL C1100(CS24-TY)最新BIOS(S99C3B25)和BMC(1.86)

    但是网上玩家已经试出了更新标准版BIOS和BMC的方法(见下面英文介绍的步骤)。不过我嫌麻烦,没有做CMOS放电的步骤,也成功了。 ---------------------------------------------------------------------------------...

    金盾视频加密器V2014 - 支持WIN8,支持32位和64位操作系统

    可以加密各种视频音频格式文件(wmv, avi, asf, mpg, rm, rmvb, mp4, flv, mp3, vob, mov, mkv, mpeg, dat等等其他各种音频视频格式,只要装上相关解码器可以支持所有视频格式),加密后的文件可以通过离线方式授权...

    二十四点源程序

    This is an icon file, which is used as the application s icon. This icon is included by the main resource file xieyuying.rc resxieyuying.rc2 This file contains resources that are not edited by ...

    利用HTML5 Canvas制作一个简单的打飞机游戏

    之前在当耐特的DEMO里看到个打飞机的游戏,然后就把... 步入主题啦:打飞机游戏文件有index.html入口文件,allSprite.js精灵的逻辑处理文件,loading.js加载处理文件以及data.js(初始化的一些数据)。  首先,正常的

    Qt调用Echats图表代码

    ECharts最初由百度团队开源,并于2018年初捐赠给Apache基金会,成为ASF孵化级项目。 这个资源项目,主要是使用Qt对echats的图表进行显示,windows10,Qt5.15.2,MSVC2019。安装qt时需要勾选webengine模块。编译运行...

    flash shiti

    45.新增图层的方法有: A. 选择Insert菜单下的Layer命令 B. 按下图层编辑区左下方的钮 C. 按下图层编辑区左下方的钮 D. 选择File菜单下的Layer命令 FLASH 样题参考答案 1.D 2.D 3.C 4.B 5.B 6.A 7.D 8.B 9.D ...

    ELDK使用与开发手册

    不过最常见的做法是使用你本机的串口,这时,你主机需要安装一个终端程序,如cu或者kermit。 4.2 配置“kermit” kermit这个名字就代表了它是连接串口和网络的通信软件。事实上在很多计算机和操作系统上使用它,能够...

    jQuery完全实例.rar

    Allows you to bind a function to be executed when the DOM document has finished loading. This function behaves just like $(document).ready(), in that it should be used to wrap other $() operations on ...

    Visual C++ 编程资源大全(英文源码 其它)

    17.zip Custom built files 自定义生成的文件(5KB)<END><br>18,18.zip Define Method 定义方法(5KB)<END><br>19,19.zip Export Makefile 输出工程制作文件(5KB)<END><br>20,20.zip Jump to ...

Global site tag (gtag.js) - Google Analytics