Packageflash.media
Classpublic class MediaPromise
InheritanceMediaPromise Inheritance EventDispatcher Inheritance Object
ImplementsIFilePromise

Language version: ActionScript 3.0
Runtime version: AIR 2.5

The MediaPromise class represents the promise to deliver a media object.

The data property of a MediaEvent object is a MediaPromise instance. You can use the MediaPromise methods to access the promised media object. Supported media formats include still images and video.

You cannot create a MediaPromise object. Calling new MediaPromise() generates a run-time error.

See also

MediaEvent
IFilePromise
Loader.LoadFilePromise()
IDataInput
CameraRoll.browseForImage()
CameraUI


Public Properties
 PropertyDefined by
 Inheritedconstructor : Object
A reference to the class object or constructor function for a given object instance.
Object
  file : File
[read-only] The File instance representing the media object, if one exists.
MediaPromise
  isAsync : Boolean
[read-only] Reports whether the underlying data source is asynchronous or synchronous.
MediaPromise
  mediaType : String
[read-only] The general type of media, either image or video.
MediaPromise
 Inheritedprototype : Object
[static] A reference to the prototype object of a class or function object.
Object
  relativePath : String
[read-only] The file name of the media object, if one exists.
MediaPromise
Public Methods
 MethodDefined by
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
Registers an event listener object with an EventDispatcher object so that the listener receives notification of an event.
EventDispatcher
  
Closes the data source.
MediaPromise
 Inherited
Dispatches an event into the event flow.
EventDispatcher
 Inherited
Checks whether the EventDispatcher object has any listeners registered for a specific type of event.
EventDispatcher
 Inherited
Indicates whether an object has a specified property defined.
Object
 Inherited
Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter.
Object
  
Opens the underlying data source and returns the IDataInput instance allowing you to read it.
MediaPromise
 Inherited
Indicates whether the specified property exists and is enumerable.
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
Removes a listener from the EventDispatcher object.
EventDispatcher
  
Used by the runtime to report errors.
MediaPromise
 Inherited
Sets the availability of a dynamic property for loop operations.
Object
 Inherited
Returns the string representation of this object, formatted according to locale-specific conventions.
Object
 Inherited
Returns the string representation of the specified object.
Object
 Inherited
Returns the primitive value of the specified object.
Object
 Inherited
Checks whether an event listener is registered with this EventDispatcher object or any of its ancestors for the specified event type.
EventDispatcher
Events
 EventSummaryDefined by
 Inherited [broadcast event] Dispatched when the Flash Player or AIR application gains operating system focus and becomes active.EventDispatcher
   A MediaPromise object dispatches a close event when the underlying data stream has closed.MediaPromise
   A MediaPromise object dispatches a complete event when all data has been read.MediaPromise
 Inherited [broadcast event] Dispatched when the Flash Player or AIR application operating loses system focus and is becoming inactive.EventDispatcher
   A MediaPromise object dispatches an ioError event when an error is encountered while reading the underlying data stream.MediaPromise
   A MediaPromise object dispatches progress events as the data becomes available.MediaPromise
Property detail
fileproperty
file:File  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 2.5

The File instance representing the media object, if one exists.

This property references a File object if the underlying data source is file-based and the file is accessible to your application. Otherwise, the property is null.

Implementation
    public function get file():File
isAsyncproperty 
isAsync:Boolean  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 2.5

Reports whether the underlying data source is asynchronous or synchronous.

Implementation
    public function get isAsync():Boolean
mediaTypeproperty 
mediaType:String  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 2.5

The general type of media, either image or video.

The constants in the MediaType class define possible values of this property:

Implementation
    public function get mediaType():String

See also

relativePathproperty 
relativePath:String  [read-only]

Language version: ActionScript 3.0
Runtime version: AIR 2.5

The file name of the media object, if one exists.

A file name is available if the underlying data source is file-based and the file is accessible to your application. Otherwise, the property is null.

Implementation
    public function get relativePath():String
Method detail
close()method
public function close():void

Language version: ActionScript 3.0
Runtime version: AIR 2.5

Closes the data source.

open()method 
public function open():IDataInput

Language version: ActionScript 3.0
Runtime version: AIR 2.5

Opens the underlying data source and returns the IDataInput instance allowing you to read it.

If the underlying data source is asynchronous, then the MediaPromise object dispatches progress and complete events to indicate whether data is available to be read. If the data source is synchronous, all data is available immediately and these events are not dispatched.

Note: You can load a MediaPromise object using the loadFilePromise() method of the Loader class instead of reading the data manually.

Returns
IDataInput

See also

reportError()method 
public function reportError(e:ErrorEvent):void

Language version: ActionScript 3.0
Runtime version: AIR 2.5

Used by the runtime to report errors.

Application code should not call this method.

Parameters
e:ErrorEvent — the error vent to dispatch.
Event detail
closeevent 
Event object type: flash.events.Event
Event.type property = flash.events.Event.CLOSE

Language version: ActionScript 3.0
Runtime version: AIR 2.5

A MediaPromise object dispatches a close event when the underlying data stream has closed.

The Event.CLOSE constant defines the value of the type property of a close event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object whose connection has been closed.
completeevent  
Event object type: flash.events.Event
Event.type property = flash.events.Event.COMPLETE

Language version: ActionScript 3.0
Runtime version: AIR 2.5

A MediaPromise object dispatches a complete event when all data has been read. The event indicates that there is no more data available in the underlying stream.

A complete event is not dispatched by a synchronous data source.

The Event.COMPLETE constant defines the value of the type property of a complete event object.

This event has the following properties:

PropertyValue
bubblesfalse
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe network object that has completed loading.
ioErrorevent  
Event object type: flash.events.IOErrorEvent

Language version: ActionScript 3.0
Runtime version: AIR 2.5

A MediaPromise object dispatches an ioError event when an error is encountered while reading the underlying data stream. No more data can be read after this event is dispatched.

progressevent  
Event object type: flash.events.ProgressEvent
ProgressEvent.type property = flash.events.ProgressEvent.PROGRESS

Language version: ActionScript 3.0
Runtime version: AIR 2.5

A MediaPromise object dispatches progress events as the data becomes available.

The bytesTotal property of all progress events except the last has the value 0. If all the data is available immediately, no progress events may be dispatched. No progress events are dispatched by synchronous data sources.

Defines the value of the type property of a progress event object.

This event has the following properties:

PropertyValue
bubblesfalse
bytesLoadedThe number of items or bytes loaded at the time the listener processes the event.
bytesTotalThe total number of items or bytes that ultimately will be loaded if the loading process succeeds.
cancelablefalse; there is no default behavior to cancel.
currentTargetThe object that is actively processing the Event object with an event listener.
targetThe object reporting progress.