flash.events
public class ProgressEvent
继承ProgressEvent Inheritance Event Inheritance Object
子类 VideoProgressEvent

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

开始加载操作或套接字已接收到数据后,Flash ® Player 将调度 ProgressEvent 对象。 这些事件通常在将 SWF 文件、图像或数据加载到 Flash Player 中时生成。 有两种类型的进程事件:ProgressEvent.PROGRESSProgressEvent.SOCKET_DATA

查看示例

另请参见

LoaderInfo class
Socket class



公共 属性
 属性定义方
 Inheritedbubbles : Boolean
[read-only] 指示事件是否为冒泡事件。
Event
  bytesLoaded : uint
在侦听器处理事件时加载的项数或字节数。
ProgressEvent
  bytesTotal : uint
如果加载过程成功,将加载的总项数或总字节数。
ProgressEvent
 Inheritedcancelable : Boolean
[read-only] 指示是否可以阻止与事件相关联的行为。
Event
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 InheritedcurrentTarget : Object
[read-only] 当前正在使用某个事件侦听器处理 Event 对象的对象。
Event
 InheritedeventPhase : uint
[read-only] 事件流中的当前阶段。
Event
 Inheritedprototype : Object
[static] 对类或函数对象的原型对象的引用。
Object
 Inheritedtarget : Object
[read-only] 事件目标。
Event
 Inheritedtype : String
[read-only] 事件的类型。
Event
公共 方法
 方法定义方
  
ProgressEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, bytesLoaded:uint = 0, bytesTotal:uint = 0)
创建一个 Event 对象,其中包含有关进度事件的信息。
ProgressEvent
  
创建 ProgressEvent 对象的副本,并设置每个属性的值以匹配原始属性值。
ProgressEvent
 Inherited
formatToString(className:String, ... arguments):String
在自定义 Event 类中实现 toString() 方法的实用程序函数。
Event
 Inherited
指示对象是否已经定义了指定的属性。
Object
 Inherited
检查是否已对事件调用 preventDefault()。
Event
 Inherited
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
如果可以取消事件的默认行为,则取消该行为。
Event
 Inherited
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
设置循环操作动态属性的可用性。
Object
 Inherited
防止对事件流中当前节点中和所有后续节点中的事件侦听器进行处理。
Event
 Inherited
防止对事件流中当前节点的后续节点中的所有事件侦听器进行处理。
Event
  
返回一个字符串,其中包含 ProgressEvent 对象的所有属性。
ProgressEvent
 Inherited
返回指定对象的原始值。
Object
公共 常量
 常量定义方
 InheritedACTIVATE : String = "activate"
[static] 定义 activate 事件对象的 type 属性值。
Event
 InheritedADDED : String = "added"
[static] 定义 added 事件对象的 type 属性值。
Event
 InheritedADDED_TO_STAGE : String = "addedToStage"
[static] 定义 addedToStage 事件对象的 type 属性值。
Event
 InheritedCANCEL : String = "cancel"
[static] 定义 cancel 事件对象的 type 属性值。
Event
 InheritedCHANGE : String = "change"
[static] 定义 change 事件对象的 type 属性值。
Event
 InheritedCLOSE : String = "close"
[static] 定义 close 事件对象的 type 属性值。
Event
 InheritedCOMPLETE : String = "complete"
[static] 定义 complete 事件对象的 type 属性值。
Event
 InheritedCONNECT : String = "connect"
[static] 定义 connect 事件对象的 type 属性值。
Event
 InheritedDEACTIVATE : String = "deactivate"
[static] 定义 deactivate 事件对象的 type 属性值。
Event
 InheritedENTER_FRAME : String = "enterFrame"
[static] 定义 enterFrame 事件对象的 type 属性值。
Event
 InheritedFULLSCREEN : String = "fullScreen"
[static] 定义 fullScreen 事件对象的 type 属性值。
Event
 InheritedID3 : String = "id3"
[static] 定义 id3 事件对象的 type 属性值。
Event
 InheritedINIT : String = "init"
[static] 定义 init 事件对象的 type 属性值。
Event
 InheritedMOUSE_LEAVE : String = "mouseLeave"
[static] 定义 mouseLeave 事件对象的 type 属性值。
Event
 InheritedOPEN : String = "open"
[static] 定义 open 事件对象的 type 属性值。
Event
  PROGRESS : String = "progress"
[static] 定义 progress 事件对象的 type 属性值。
ProgressEvent
 InheritedREMOVED : String = "removed"
[static] 定义 removed 事件对象的 type 属性值。
Event
 InheritedREMOVED_FROM_STAGE : String = "removedFromStage"
[static] 定义 removedFromStage 事件对象的 type 属性值。
Event
 InheritedRENDER : String = "render"
[static] 定义 render 事件对象的 type 属性值。
Event
 InheritedRESIZE : String = "resize"
[static] 定义 resize 事件对象的 type 属性值。
Event
 InheritedSCROLL : String = "scroll"
[static] 定义 scroll 事件对象的 type 属性值。
Event
 InheritedSELECT : String = "select"
[static] 定义 select 事件对象的 type 属性值。
Event
  SOCKET_DATA : String = "socketData"
[static] 定义 socketData 事件对象的 type 属性值。
ProgressEvent
 InheritedSOUND_COMPLETE : String = "soundComplete"
[static] 定义 soundComplete 事件对象的 type 属性值。
Event
 InheritedTAB_CHILDREN_CHANGE : String = "tabChildrenChange"
[static] 定义 tabChildrenChange 事件对象的 type 属性值。
Event
 InheritedTAB_ENABLED_CHANGE : String = "tabEnabledChange"
[static] 定义 tabEnabledChange 事件对象的 type 属性值。
Event
 InheritedTAB_INDEX_CHANGE : String = "tabIndexChange"
[static] 定义 tabIndexChange 事件对象的 type 属性值。
Event
 InheritedUNLOAD : String = "unload"
[static] 定义 unload 事件对象的 type 属性值。
Event
属性详细信息
bytesLoaded属性
bytesLoaded:uint  [read-write]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

在侦听器处理事件时加载的项数或字节数。


实现
    public function get bytesLoaded():uint
    public function set bytesLoaded(value:uint):void
bytesTotal属性 
bytesTotal:uint  [read-write]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

如果加载过程成功,将加载的总项数或总字节数。


实现
    public function get bytesTotal():uint
    public function set bytesTotal(value:uint):void
构造函数详细信息
ProgressEvent()构造函数
public function ProgressEvent(type:String, bubbles:Boolean = false, cancelable:Boolean = false, bytesLoaded:uint = 0, bytesTotal:uint = 0)

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

创建一个 Event 对象,其中包含有关进度事件的信息。 将 Event 对象作为参数传递给事件侦听器。

参数
type:String — 事件的类型。 可能的值包括:ProgressEvent.PROGRESSProgressEvent.SOCKET_DATA
 
bubbles:Boolean (default = false) — 确定 Event 对象是否参与事件流的冒泡阶段。
 
cancelable:Boolean (default = false) — 确定是否可以取消 Event 对象。
 
bytesLoaded:uint (default = 0) — 在侦听器处理事件时加载的项数或字节数。
 
bytesTotal:uint (default = 0) — 如果加载过程成功,将加载的总项数或总字节数。
方法详细信息
clone()方法
public override function clone():Event

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

创建 ProgressEvent 对象的副本,并设置每个属性的值以匹配原始属性值。

返回
Event — 其属性值与原始属性值匹配的新 ProgressEvent 对象。
toString()方法 
public override function toString():String

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

返回一个字符串,其中包含 ProgressEvent 对象的所有属性。 字符串的格式如下:

[ProgressEvent type=value bubbles=value cancelable=value bytesLoaded=value bytesTotal=value]

返回
String — 一个字符串,其中包含 ProgressEvent 对象的所有属性。
常量详细信息
PROGRESS常量
public static const PROGRESS:String = "progress"

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

定义 progress 事件对象的 type 属性值。

此事件具有以下属性:

属性
bubblesfalse
bytesLoaded在侦听器处理事件时加载的项数或字节数。
bytesTotal如果加载进程成功,最终将加载的项目或字节总数。
cancelablefalse;没有要取消的默认行为。
currentTarget当前正在使用某个事件侦听器处理 Event 对象的对象。
target报告进度的网络对象。

另请参见

SOCKET_DATA常量 
public static const SOCKET_DATA:String = "socketData"

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9

定义 socketData 事件对象的 type 属性值。

此事件具有以下属性:

属性
bubblesfalse
cancelablefalse;没有要取消的默认行为。
currentTarget当前正在处理此事件的对象。
bytesLoaded在侦听器处理事件时加载的项数或字节数。
bytesTotal0;socketData 事件对象不使用此属性。
target报告进度的 Socket 对象。

另请参见

示例 如何使用示例

以下示例使用 ProgressEventExample 类来说明如何在下载文件时使用各种事件侦听器。 该示例执行下列任务:
  1. 创建 downloadURLfileName 属性,这些属性指示下载文件的位置和名称。
  2. ProgressEventExample 构造函数中,创建名为 file 的新 FileReference 对象,再将其传递给 configureListeners() 方法。
  3. 然后将 downloadURLfileName 属性传递给 file.download(),它提示要下载文件的位置。
  4. configureListeners() 方法添加七个事件侦听器及其关联的订阅者方法:

    1. cancel / cancelHandler() 在取消文件下载时调度。
    2. complete / complereHandler() 在完成文件下载进程时调度。
    3. ioError / ioErrorHandler() 在下载文件不可用或不可访问时调度。
    4. open / openHandler() 在已开始下载操作时调度。
    5. progress / progressHandler() 在下载进程开始时调度并在进程结束时再次调度。
    6. securityError / securityErrorHandler 在本地回放安全性设置与下载文件的数据访问类型(本地与网络)不匹配时调度;请参阅下面的备注。
    7. select / selectHandler() 在选择下载对象时调度。

注意:


package {
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.FileReference;
    import flash.net.URLRequest;

    public class ProgressEventExample extends Sprite {
        private var downloadURL:String = "http://www.[yourDomain].com/SomeFile.pdf";
        private var fileName:String = "SomeFile.pdf";
        private var file:FileReference;

        public function ProgressEventExample() {
            var request:URLRequest = new URLRequest(downloadURL);
            file = new FileReference();
            configureListeners(file);
            file.download(request, fileName);
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
            dispatcher.addEventListener(Event.CANCEL, cancelHandler);
            dispatcher.addEventListener(Event.COMPLETE, completeHandler);
            dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
            dispatcher.addEventListener(Event.OPEN, openHandler);
            dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
            dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
            dispatcher.addEventListener(Event.SELECT, selectHandler);
        }

        private function cancelHandler(event:Event):void {
            trace("cancelHandler: " + event);
        }

        private function completeHandler(event:Event):void {
            trace("completeHandler: " + event);
        }

        private function ioErrorHandler(event:IOErrorEvent):void {
            trace("ioErrorHandler: " + event);
        }

        private function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        private function progressHandler(event:ProgressEvent):void {
            var file:FileReference = FileReference(event.target);
            trace("progressHandler: name=" + file.name + " bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }

        private function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        private function selectHandler(event:Event):void {
            var file:FileReference = FileReference(event.target);
            trace("selectHandler: name=" + file.name + " URL=" + downloadURL);
        }
    }
}




 

评论添加到页面后给我发送电子邮件 | 评论报告

当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/flash/events/ProgressEvent.html