Setting up a server to communicate with the XMLSocket object can be challenging. If your application does not require real-time interactivity, use the URLLoader class instead of the XMLSocket class.
To use the methods of the XMLSocket class, first use the constructor,
SWF files in the local-with-filesystem sandbox may not use sockets.
Socket policy files on the target host specify the hosts from which SWF files can make socket connections, and the ports to which those connections can be made. The security requirements with regard to socket policy files have become more stringent in the last several releases of Flash Player. In all versions of Flash Player, Adobe recommends the use of a socket policy file; in some circumstances, a socket policy file is required. Therefore, if you are using XMLSocket objects, make sure that the target host provides a socket policy file if necessary.
The following list summarizes the requirements for socket policy files in different versions of Flash Player:
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
Notes:
Note: It is strongly advised to use the constructor form without parameters, then
add any event listeners, then call the
If you specify
You can prevent a file from using this method by setting the
For more information, see the Flash Player Developer Center Topic:
If you do not connect the XMLSocket object to the server using
If the connection doesn't succeed within the specified time, the connection fails. The default value is 20,000 (twenty seconds).
IPv4 addresses are expressed in ActionScript as a string in dot-decimal notation, such as:
IPv6 addresses are expressed in ActionScript as a string in hexadecimal-colon notation and enclosed in
brackets, such as:
The Socket class is useful for working with servers that use binary protocols.
To use the methods of the Socket class, first use the constructor,
A socket transmits and receives data asynchronously.
On some operating systems, flush() is called automatically between execution frames, but on other operating systems, such
as Windows, the data is never sent unless you call
In Adobe AIR, Socket objects are also created when a listening ServerSocket receives a connection from an external process. The Socket representing the connection is dispatched in a ServerSocketConnectEvent. Your application is responsible for maintaining a reference to this Socket object. If you don't, the Socket object is eligible for garbage collection and may be destroyed by the runtime without warning.
SWF content running in the local-with-filesystem security sandbox cannot use sockets.
Socket policy files on the target host specify the hosts from which SWF files can make socket connections, and the ports to which those connections can be made. The security requirements with regard to socket policy files have become more stringent in the last several releases of Flash Player. In all versions of Flash Player, Adobe recommends the use of a socket policy file; in some circumstances, a socket policy file is required. Therefore, if you are using Socket objects, make sure that the target host provides a socket policy file if necessary.
The following list summarizes the requirements for socket policy files in different versions of Flash Player:
For more information related to security, see the Flash Player Developer Center Topic:
Note: To run the example, you need a server running on the same domain
where the SWF resides (in the example,
Note: In an AIR application, content running in the application security sandbox is permitted to connect to any server and port number without a socket policy file.
The data received by the socket remains in the socket until it is read. You do not have to read all the available data during the handler for this event.
Events of type
The
Note: It is strongly advised to use the constructor form without parameters, then
add any event listeners, then call the
The
You can reuse the Socket object by calling the
If the connection fails immediately, either an event is dispatched or an exception is thrown: an error event is dispatched if a host was specified, and an exception is thrown if no host was specified. Otherwise, the status of the connection is reported by an event. If the socket is already connected, the existing connection is closed first.
On some operating systems, flush() is called automatically between execution frames, but on other operating systems, such
as Windows, the data is never sent unless you call
Note: If the value for the
If you omit the
If you also omit the
(v >> 8) & 0xff v & 0xff
The low 16 bits of the parameter are used; the high 16 bits are ignored.
Before writing the string, the method calculates the number of bytes that are needed to represent all characters of the string.
Your code must access
You can use this property to determine the IP address of a client socket dispatched in a ServerSocketConnectEvent by a ServerSocket object. Use the DNSResolver class to convert an IP address to a domain name, if desired.
You can use this property to determine the port number of a client socket dispatched in a ServerSocketConnectEvent by a ServerSocket object.
If the connection doesn't succeed within the specified time, the connection fails. The default value is 20,000 (twenty seconds).
Object encoding controls how objects are represented in Action Message Format (AMF). Flash Player uses AMF to enable efficient communication between an application and a remote server. AMF encodes remote procedure calls into a compact binary representation that can be transferred over HTTP/HTTPS or the RTMP/RTMPS protocol used by Flash Media Server. Objects and data values are serialized into this binary format, which is generally more compact than other representations, such as XML.
Adobe AIR and Flash Player 9 can serialize in two different formats: AMF3 and AMF0.
AMF3, the default serialization developed for ActionScript 3.0, provides various advantages
over AMF0, which is used for ActionScript 1.0 and 2.0. AMF3 sends data over
the network more efficiently than AMF0.
The ByteArray, FileStream, NetConnection, NetStream,
For example, if an object has the
This value is called only for properties of a dynamic object (objects declared
within a dynamic class) or for objects declared using the
You can use this property to exclude properties of dynamic objects from serialization; to write values to properties of dynamic objects; or to create new properties for dynamic objects. To do so, set this property to an object that implements the IDynamicPropertyWriter interface. For more information, see the IDynamicPropertyWriter interface.
Two of the constants indicate a timescale discontinuity. Every FLV tag has a timestamp indicating its position in the timescale. Timestamps are used to synchronize video, audio, and script data playback. Timestamps for FLV tags of the same type (video, audio, script data) must not decrease as the FLV progresses.
A URLLoader object downloads all of the data from a URL before
making it available to code in the applications. It sends out
notifications about the progress of the download, which you can monitor
through the
When loading very large video files, such as FLV's, out-of-memory errors may occur.
When you use this class
For more information related to security, see the Flash Player Developer Center Topic:
Note: To run this example, put a file named urlLoaderExample.txt
in the same directory as your SWF file. That file should only contain the following line of text:
The example code does the following:
Note that with a URLLoader object, it is not possible to access the data until it has been received completely. So, the progress event only serves as a notification of how far the download has progressed. To access the data before it's entirely downloaded, use a URLStream object.
The function can have any name.
Class-level member functions are not subject to garbage
collection, so you can set
After you successfully register an event listener, you cannot change its priority
through additional calls to
Keep in mind that after the listener is registered, subsequent calls to
You cannot register an event listener for only the target phase or the bubbling phase. Those phases are coupled during registration because bubbling applies only to the ancestors of the target node.
If you no longer need an event listener, remove it by calling
Copying an EventDispatcher instance does not copy the event listeners attached to it. (If your newly created node needs an event listener, you must attach the listener after creating the node.) However, if you move an EventDispatcher instance, the event listeners attached to it move along with it.
If the event listener is being registered on a node while an event is being processed on this node, the event listener is not triggered during the current phase but can be triggered during a later phase in the event flow, such as the bubbling phase.
If an event listener is removed from a node while an event is being processed on the node, it is still triggered by the current actions. After it is removed, the event listener is never invoked again (unless registered again for future processing).
Note: If a file being loaded contains non-ASCII characters (as found in many non-English languages), it is recommended that you save the file with UTF-8 or UTF-16 encoding as opposed to a non-Unicode format like ASCII.
A SWF file in the local-with-filesystem sandbox may not load data from, or provide data to, a resource that is in the network sandbox.
By default, the calling SWF file and the URL you load must be in exactly the same domain. For example, a SWF file at www.adobe.com can load data only from sources that are also at www.adobe.com. To load data from a different domain, place a URL policy file on the server hosting the data.
You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
For more information related to security, see the Flash Player Developer Center Topic:
A
In the
If the value of the
If the value of the
If the value of the
If the
If the
If the
If you pass a positive number for
If you pass a negative number other than -1 for
Fast switch
When this property is specified, Flash Media Server pre-empts the current stream and starts streaming the new stream from the specified index position immediately, without waiting to find a keyframe. Any data after the offset already buffered from a previous stream is flushed. This technique can switch to a new stream more quickly than standard switching, because the buffered data from an older stream doesn't have to play out.
The default value of
The offset value must be higher than the current playback time (
For more information, see
The default value for
If you pass -1 for
If you pass 0 or a positive number for
If you pass a negative number other than -1 or -2 for
Properties that return numbers represent totals computed from the beginning of the multicast stream. These types of properties include the number of media bytes sent or the number of media fragment messages received. Properties that are rates represent a snapshot of the current rate averaged over a few seconds. These types of properties include the rate at which a local node is receiving data.
To see a list of values contained in the NetStreamMulticastInfo object, use the
AIR profile support: This feature is supported
on all desktop operating systems and AIR for TV devices, but is not supported on all mobile devices.
You can test for support at run time using the
The NetworkInfo object is a singleton. To get the single NetworkInfo object,
use the static
Most computers have one or more interfaces, such as a wired and a wireless network interface. Additional interfaces such as VPN, loopback, or virtual interfaces can also be present.
A NetworkInfo object dispatches a change event when the available
interfaces change. Call the
Note: The NativeApplication object also dispatches network change events.
Highlights of the example follow:
Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by Flash Player in the URLVariables object.
If you call the URLVariables constructor with a string,
the
This method is used internally by the URLVariables events. Most users do not need to call this method directly.
AIR profile support: This feature is supported on
all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test for
support at run time using the
Datagram packets are individually transmitted between the source and destination. Packets can arrive in a different order than they were sent. Packets lost in transmission are not retransmitted, or even detected.
Data sent using a datagram socket is not automatically broken up into packets of transmittable size. If you send a UDP packet that exceeds the maximum transmission unit (MTU) size, network discards the packet (without warning). The limiting MTU is the smallest MTU of any interface, switch, or router in the transmission path. You can use the NetworkInterface class to determine the MTU of the local interface, but other nodes in the network can have different MTU values.
The Socket class uses TCP which provides guaranteed packet delivery and automatically divides and reassembles large packets. TCP also provides better network bandwidth management. These features mean that data sent using a TCP socket incurs higher latency, but for most uses, the benefits of TCP far outweigh the costs. Most network communication should use the Socket class rather than the DatagramSocket class.
The DatagramSocket class is useful for working with applications where a small transmission latency is important and packet loss is tolerable. For example, network operations in voice-over-IP (VoIP) applications and real-time, multiplayer games can often benefit from UDP. The DatagramSocket class is also useful for some server-side applications. Since UDP is a stateless protocol, a server can handle more requests from more clients than it can with TCP.
The DatagramSocket class can only be used in Adobe AIR applications and only in the application security sandbox.
For more information related to security, see the Flash Player Developer Center Topic:
The
The
The socket is disconnected from the remote machine and unbound from the local machine. A closed socket cannot be reused.
When a datagram socket is "connected," datagram packets can only be sent to and received from the specified target. Packets from other sources are ignored. Connecting a datagram socket is not required. Establishing a connection can remove the need to filter out extraneous packets from other sources. However, a UDP socket connection is not a persistent network connection (as it is for a TCP connection). It is possible that the remote end of the socket does not even exist.
If the
The function returns immediately. The DatagramSocket object dispatches a
If the socket is connected, the packet
is sent to the remote address and port specified in the
Note: Sending data to a broadcast address is not supported.
Note: A value of
Any properties set in a URLRequest object override those static properties set for the URLRequestDefaults class.
URLRequestDefault settings only apply to content in the caller's application domain,
with one exception: settings made by calling
Only Adobe® AIR® content running in the application security sandbox can use the URLRequestDefaults class. Other content will result in a SecurityError being thrown when accessing the members or properties of this class.
Note for applications running on Mac OS: On Mac OS, when you call
this method, the application uses these credentials for the specified host
until the application is closed, even if you subsequently call
Note: This method does not apply to URLRequest objects used in file upload or RTMP requests.
Note: This setting does not apply to URLRequest objects used in file upload or RTMP requests.
The idle timeout is the amount of time (in milliseconds) that the client waits for a response from the server, after the connection is established, before abandoning the request.
This defines the default idle timeout used by the URLRequest or HTMLLoader object. Setting the
When this property is set to 0 (the default), the runtime uses the default idle timeout value defined by the operating system. The default idle timeout value varies between operating systems (such as Mac OS, Linux, or Windows) and between operating system versions.
This setting does not apply to URLRequest objects used in file upload or RTMP requests.
Note: This setting does not apply to URLRequest objects used in file upload or RTMP requests.
This is also the default user agent string for all HTMLLoader objects (used
when you call the
This default value varies depending on the runtime operating system (such as Mac OS, Linux or Windows), the runtime language, and the runtime version, as in the following examples:
In the client-side NetGroup class, the NetConnection dispatches the following events:
The
For information about peer-assisted networking, see
For information about the technical details behind peer-assisted networking, see
When you run the application, you can enter any group name into the text input field. The GroupSpecifier class uses the name (along with any GroupSpecifier properties you've set) to create a string which is the perpetually unique name of the group. To connect another client to the group, that client must use the same group name. For example, if client A uses the group name "firstmesh", other clients that want to communicate with client A must also use the group name "firstmesh". If client B uses the group name "kite", it will connect successfully, but it will create a new group and won't be able to communicate with client A or anyone in the "firstmesh" group.
In most cases, a
Note: When a client subscribes to a native-IP multicast stream, the security dialog is not displayed.
For more information about object replication,
see
This method sends a NetStatusEvent to the NetGroup's event listener with
NOTE: Test for the
For more information about object replication,
see
This method sends a NetStatusEvent to the NetGroup's event listener with
NOTE: Test for the
For more information about object replication,
see
NOTE: Test for the
All messages must be unique. A message that is identical to one posted earlier might not be propagated. Use a sequence number to make messages unique.
Message delivery is not ordered. Message delivery is not guaranteed.
Messages are serialized in AMF. The message can be one of the following types: an Object, an int, a Number, or a String. The message cannot be a MovieClip.
This method sends a NetStatusEvent to the NetGroup's event listener
with
NOTE: Test for the
When you run the application, you can enter any group name into the text input field. The GroupSpecifier class uses the name (along with any GroupSpecifier properties you've set) to create a string which is the perpetually unique name of the group. To connect another client to the group, that client must use the same group name. For example, if client A uses the group name "firstmesh", other clients that want to communicate with client A must also use the group name "firstmesh". If client B uses the group name "kite", it will connect successfully, but it will create a new group and won't be able to communicate with client A or anyone in the "firstmesh" group.
To run this example, add a Button, a Label, a TextInput, and a TextArea component to the Library in Flash Pro.
For more information about object replication,
see
NOTE: Test for the
For more information about object replication,
see
NOTE: Test for the
For more information about routing messages, see
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener
with
NOTE: Test for the
For more information about routing messages, see
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener
with
NOTE: Test for the
For more information about routing messages, see
When a node receives a message, a NetStatusEvent is sent to the NetGroup's event listener
with
NOTE: Test for the
For more information about object replication,
see
NOTE: Test for the
This method does not interact with the
If you do not specify a value for this parameter, a new empty window is created.
In the stand-alone player, you can either specify a new (
Note: When code in a SWF file that is running in the
local-with-filesystem sandbox calls the
Important Security Note
Developers often pass URL values to the
Good data validation for URLs can mean different things depending on the usage of the URL within the overall application. The most common data validation techniques include validating that the URL is of the appropriate scheme. For instance, unintentionally allowing javascript: URLs may result in cross-site scripting. Validating that the URL is a within your domain can ensure that the SWF file can't be used as an open-redirector by people who conduct phishing attacks. For additional security, you may also choose to validate the path of the URL and to validate that the URL conforms to the RFC guidelines
For example, the following code shows a simple example of performing data validation by denying any URL that does not begin with http:// or https:// and validating that the URL is within your domain name. This example may not be appropriate for all web applications and you should consider whether additional checks against the URL are necessary.
For local content running in a browser, calls to the
In Flash Player, and in non-application sandboxes in Adobe AIR, you cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
In Flash Player 10 and later running in a browser, using this method programmatically to open a pop-up window may not be successful. Various browsers (and browser configurations) may block pop-up windows at any time; it is not possible to guarantee any pop-up window will appear. However, for the best chance of success, use this method to open a pop-up window only in code that executes as a direct result of a user action (for example, in an event handler for a mouse click or key-press event.)
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
In AIR, on mobile platforms, the sms: and tel: URI schemes are supported. On Android, vipaccess:, connectpro:, and market: URI schemes are supported.
The URL syntax is subject to the platform conventions. For example, on Android, the URI scheme must be lower case.
When you navigate to a URL using one of these schemes, the runtime opens the URL in the default application for
handling the scheme. Thus, navigating to
The following code shows how you can invoke the VIP Access and Connect Pro applications on Android:
LocalConnection, ByteArray, SharedObject, NetConnection and NetStream are all examples of classes that encode objects in AMF.
The encoding and decoding contexts do not need to use the same class for an alias; they can intentionally change classes, provided that the destination class contains all of the members that the source class serializes.
To examine the server response, use the
You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
You can prevent a SWF file from using this method by setting the
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
For more information related to security, see the Flash Player Developer Center Topic:
If you want to enable distributed routing behavior, set this value
to
In Adobe® AIR®, content in the application security sandbox (such as
content installed with the AIR application) can use any request headers, without error. However, for content
running in Adobe AIR that is in a different security sandbox,
In Flash Player and in Adobe AIR content outside of the application security sandbox,
the following request headers cannot be used, and the restricted terms are not case-sensitive
(for example,
URLRequestHeader objects are restricted in length. If the cumulative length of a
URLRequestHeader object (the length of the
Content running in Adobe AIR sets the
Not all methods that accept URLRequest parameters support the
Due to browser limitations, custom HTTP request headers are only supported for
Note:To run this example, put a file named example.txt in the same directory as your SWF file. That file should be a simple text file containing a few words or lines of text.
The example code does the following:
Note:
Note: In Adobe AIR, the File class, which extends the FileReference class, provides more capabilities and has less security restrictions than the FileReference class.
FileReference instances are created in the following ways:
During an upload operation, all the properties of a FileReference object are
populated by calls to the
The
The FileReference and FileReferenceList classes do not let you set the default file location
for the dialog box that the
The FileReference and FileReferenceList classes also do not provide methods for authentication. With servers that require authentication, you can download files with the Flash® Player browser plug-in, but uploading (on all players) and downloading (on the stand-alone or external player) fails. Listen for FileReference events to determine whether operations complete successfully and to handle errors.
For
Note that because of new functionality added to the Flash Player, when publishing to Flash Player 10, you can have
only one of the following operations active at one time:
While calls to the
The following sample HTTP
POST /handler.cfm HTTP/1.1 Accept: text/~~ Content-Type: multipart/form-data; boundary=----------Ij5ae0ae0KM7GI3KM7 User-Agent: Shockwave Flash Host: www.example.com Content-Length: 421 Connection: Keep-Alive Cache-Control: no-cache ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Filename" MyFile.jpg ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Filedata"; filename="MyFile.jpg" Content-Type: application/octet-stream FileDataHere ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Upload" Submit Query ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--
Flash Player sends the following HTTP
POST /handler.cfm HTTP/1.1 Accept: text/~~ Content-Type: multipart/form-data; boundary=----------Ij5ae0ae0KM7GI3KM7 User-Agent: Shockwave Flash Host: www.example.com Content-Length: 421 Connection: Keep-Alive Cache-Control: no-cache ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Filename" MyFile.jpg ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="api_sig" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="api_key" XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="auth_token" XXXXXXXXXXXXXXXXXXXXXX ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Filedata"; filename="MyFile.jpg" Content-Type: application/octet-stream FileDataHere ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7 Content-Disposition: form-data; name="Upload" Submit Query ------------Ij5GI3GI3ei4GI3ei4KM7GI3KM7KM7--
Note:
To run this example, change the uploadURL.url property to point to an actual URL,
rather than the fictional one in the example. The URL should point to a file named
The
For content running
In Adobe AIR, these security restrictions do not apply to content in the application security sandbox.
In Adobe AIR, these security restrictions do not apply to content in the application security sandbox.
In some cases,
File upload progress cannot be determined on Macintosh platforms earlier than OS X 10.3.
The
open
event.
It should be made clear that there is no way to actually track the progress
of a download, just that it hasn't yet finished or failed.
ioError
event.
Note that for simplicity, none of the other event types are used in this
example.
Important: Only applications running in a browser — that is, using the browser plug-in or ActiveX control — and content running in Adobe AIR can provide a dialog box to prompt the user to enter a user name and password for authentication, and then only for downloads. For uploads using the plug-in or ActiveX control version of Flash Player, or for upload or download using either the stand-alone or the external player, the file transfer fails.
complete
event
listener. It should be made clear that there is no way to actually track the progress
of a download, just that it hasn't yet finished or failed.
FileReference
object and
initiates the download of a pdf file.
Note: The File class, available in Adobe AIR, includes methods for
accessing more specific system file selection dialog boxes. These methods are
When you call this method and the user
successfully selects a file, the properties of this FileReference object are populated with
the properties of that file. Each subsequent time that the
Using the
In Flash Player 10 and Flash Player 9 Update 5, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception.
Note that because of new functionality added to the Flash Player, when publishing to Flash Player 10, you can have
only one of the following operations active at one time:
In Adobe AIR, the file-browsing dialog is not always displayed in front of windows that are
"owned" by another window (windows that have a non-null
On some browsers, URL strings are limited in length. Lengths greater than 256 characters may fail on some browsers or servers.
If you omit this parameter, the filename of the remote URL is parsed and used as the default.
The
The
When the file is downloaded successfully, the
properties of the FileReference object are populated with the properties
of the local file. The
Only one
This method supports downloading of any file type, with either HTTP or HTTPS.
You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
Note: If your server requires user authentication, only SWF files running in a browser — that is, using the browser plug-in or ActiveX control — can provide a dialog box to prompt the user for a user name and password for authentication, and only for downloads. For uploads using the plug-in or ActiveX control, or for uploads and downloads using the stand-alone or external player, the file transfer fails.
When you use this method , consider the
However,
For more information related to security, see the Flash Player Developer Center Topic:
When you download a file using this method, it is flagged as downloaded on operating systems that flag downloaded files:
Some operating systems, such as Linux, do not flag downloaded files.
Note that because of new functionality added to the Flash Player, when publishing to Flash Player 10, you can have
only one of the following operations active at one time:
In Adobe AIR, the download dialog is not always displayed in front of windows that are
"owned" by another window (windows that have a non-null
Listeners receive events to indicate the progress, success, or
failure of the load. Although you can use the FileReferenceList object to let users
select multiple files to load, you must load the files one by one. To load the files
one by one, iterate through the
Adobe AIR also includes the FileStream class which provides more options for reading files.
The
If the file finishes loading successfully, its contents are stored as a byte array
in the
The following security considerations apply:
However, these considerations do not apply to AIR content in the application sandbox.
Note that when publishing to Flash Player 10 or AIR 1.5, you can have only one of the following operations active at one time:
In Adobe AIR, the file-browsing dialog is not always displayed in front of windows that are
"owned" by another window (windows that have a non-null
If a File object calls this method, the filename will be that of the file the File object references. (The AIR File class extends the FileReference class.)
The
Adobe AIR also includes the FileStream class which provides more options for saving files locally.
The
When the file is saved successfully, the
properties of the FileReference object are populated with the properties
of the local file. The
Only one
In Flash Player, you can only call this method successfully in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error exception. This limitation does not apply to AIR content in the application sandbox.
In Adobe AIR, the save dialog is not always displayed in front of windows that are
"owned" by another window (windows that have a non-null
The URL can be HTTP or, for secure uploads, HTTPS.
To use HTTPS, use an HTTPS url in the
To send
The URL can be HTTP or, for secure uploads, HTTPS.
To use HTTPS, use an HTTPS url in the
To send
Content-Type: multipart/form-data; boundary=AaB03x --AaB03x Content-Disposition: form-data; name="Filedata"; filename="example.jpg" Content-Type: application/octet-stream ... contents of example.jpg ... --AaB03x--
For the Adobe AIR File class, which extends the FileReference class, you can use the
Listeners receive events to indicate the progress, success, or
failure of the upload. Although you can use the FileReferenceList object to let users
select multiple files for upload, you must upload the files one by one; to do so, iterate through
the
The
The file is uploaded to the URL passed in the
You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
For a sample
If the
Note: If your server requires user authentication, only SWF files running in a browser — that is, using the browser plug-in or ActiveX control — can provide a dialog box to prompt the user for a username and password for authentication, and only for downloads. For uploads using the plug-in or ActiveX control, or for uploads and downloads using the stand-alone or external player, the file transfer fails.
When you use this method , consider the
However, in Adobe AIR, content in the
For more information related to security, see the Flash Player Developer Center Topic:
Note that because of new functionality added to the Flash Player, when publishing to Flash Player 10, you can have
only one of the following operations active at one time:
A file's extension is the part of the name following (and not including) the final dot (".").
If there is no dot in the filename, the extension is
Note: You should use the
All the properties of a FileReference object are populated by calling the
Note: In the initial version of ActionScript 3.0, the
In Windows or Linux, this property is the file extension. On the Macintosh, this property is
the four-character file type, which is only used in Mac OS versions prior to Mac OS X. If the FileReference object
was not populated, a call to get the value of this property returns
For Windows, Linux, and Mac OS X, the file extension — the portion of the
To work with the FileReferenceList class:
The FileReferenceList class includes a
To run this example, place a script that is written to accept a file upload at http://www.[yourDomain].com/yourUploadHandlerScript.cfm. Based on the location of your SWF file and where you are uploading files to, you also might need to compile the SWF file with Local Playback Security set to Access Network Only or update Flash® Player security settings to allow this file network access. If your upload server is remote and you run this example from your desktop computer, your server must have a crossdomain.xml file.
select
event.
FileReferenceList
object,
iterates over each selected file, and outputs their names.
// ask the user to choose an image file for upload var fileRef = new FileReference(); if (fileRef.browse(["Images", "jpg;gif;png", "Flash Movies", "swf"])) { trace("Opened " + fileRef.name); } else { trace("User canceled"); }
In Flash Player 10 and later, you can call this method successfully only in response to a user event (for example, in an event handler for a mouse click or keypress event). Otherwise, calling this method results in Flash Player throwing an Error.
When you call this method and the user successfully selects files,
the
Using the
Only one
fileList
property.
When the
The
The properties of
You can get a list of network interfaces by calling the
The hardware address is typically the Media Access Control (MAC) address of the network adapter or interface card.
If the
This interface could have a parent if it is a subinterface. The
Subinterfaces are often virtual interfaces. The
AIR profile support: This feature is supported
on all desktop operating systems, but is not supported on all AIR for TV devices.
It is not supported on mobile devices. You can test
for support at run time using the
The SSL/TLS protocols provide a mechanism by which the identity of a host can be authenticated via its certificate, and provides for encrypted communication over the socket. SSLv3 and TLSv1 are supported. Validation of the server certificate is performed using the trust store and certificate validation support of the client platform.
The SecureSocket class will only connect to servers with valid, trusted certificates. You cannot choose to connect to a server in spite of a problem with it's certificate. For example, there is no way to connect to a server with an expired certificate or a certificate that doesn't chain to a trusted root certificate even though the certificate would be valid otherwise.
The SecureSocket class is useful for performing encrypted communication to a trusted server. In other respects a SecureSocket object behaves like a regular Socket object.
To use the methods of the SecureSocket class, first use the constructor,
Important: The Online Certificate Status Protocol (OCSP) is not supported by all operating systems. Users can also disable OCSP checking on individual computers. If OCSP is not supported or is disabled and a certificate does not contain the information necessary to check revocation using a Certificate Revocation List (CRL), then certificate revocation is not checked. The certificate is accepted if otherwise valid. This could allow a server to use a revoked certificate.
When a server certificate cannot be validated, the error event dispatched is an IOError. In this case,
you can check the
The
Check
When you call the
If the socket is already connected, the existing connection is closed first.
Secure sockets are not supported on all platforms. Check this property before attempting to create a new SecureSocket instance.
The status is
Note: Once the certificate has been validated or rejected, the status
value is not updated until the next call to the
AIR profile support: This feature is supported
on all desktop operating systems, but is not supported on mobile devices or AIR for TV devices. You can test
for support at run time using the
A TCP server listens for incoming connections from remote clients. When a client attempts to
connect, the ServerSocket dispatches a
Note: Your application is responsible for maintaining a reference to the client Socket object. If you don't, the object is eligible for garbage collection and may be destroyed by the runtime without warning.
To put a ServerSocket object into the listening state, call the
TCP connections are persistent — they exist until one side of the connection closes it (or a serious network failure occurs). Any data sent over the connection is broken into transmittable packets and reassembled on the other end. All packets are guaranteed to arrive (within reason) — any lost packets are retransmitted. In general, the TCP protocol manages the available network bandwidth better than the UDP protocol. Most AIR applications that require socket communications should use the ServerSocket and Socket classes rather than the DatagramSocket class.
The ServerSocket class can only be used in Adobe AIR applications and only in the application security sandbox.
For more information related to security, see the Flash Player Developer Center Topic:
The
Closed sockets cannot be reopened. Create a new ServerSocket instance instead.
The
The
You can use FileFilter instances in one of two ways:
The two formats are not interchangeable within a single call to the browse method. You must use one or the other.
You can pass one or more FileFilter instances to the browse method, as shown in the following:
Or in an AIR application:
The list of extensions in the
A SWF file in the local-with-filesystem sandbox may not load data from, or provide data to, a resource that is in the network sandbox.
By default, the calling
However, in Adobe AIR, content in the application security sandbox (content installed with the AIR application) is not restricted by these security limitations. For content running in Adobe AIR, files in the application security sandbox can access URLs using any of the following URL schemes:
Content
For more information related to security, see the Flash Player Developer Center Topic:
To run this example, place a file named XMLFile.xml in the same directory as your SWF file.
The supported authentication methods are:
Note:The
Note:The
The default value is
Note:The
When sending a POST request, the values of the
In Flash Player 10 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
This property is used in conjunction with the
The URLRequest API offers binary
The way in which the data is used depends on the type of object used:
This data is not sent until a method, such as
Note: The value of
Highlights of the example follow:
Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by Flash Player in the URLVariables object.
The digest is based on an SHA-256 message digest algorithm (64 characters long in hexadecimal format).
For example, the Flex SDK includes a SWZ for the Flex framework (and it
provides the digest string for that SWZ file). You can post this SWZ on your web server and load it
in your SWF file (using the
Only set the
Note:The
The idle timeout is the amount of time the client waits for a response from the server, after the connection is established, before abandoning the request.
Note: The
On Mac OS, cookies are shared with Safari. To clear cookies on Mac OS:
To clear cookies on Windows:
Highlights of the example follow:
Note: To run the example, the remote application URL in the example must be replaced with a working URL. Additionally, you would need server code to process the information captured by Flash Player in the URLVariables object.
Not all methods that accept URLRequest parameters support the
Due to browser limitations, custom HTTP request headers are only supported for
Be sure to encode any characters that are either described as unsafe in the Uniform Resource Locator
specification (see http://www.faqs.org/rfcs/rfc1738.html) or that are reserved in the
URL scheme of the URLRequest object (when not used for their reserved purpose). For example,
use
By default, the URL must be in the same domain as the calling file,
unless the content is running in the
Note: IPv6 (Internet Protocol version 6) is supported
rtmp://[2001:db8:ccc3:ffff:0:444d:555e:666f]:1935/test
Note:The
The default value is the same user agent string that is used by Flash Player, which is different on Mac, Linux, and Windows.
Note: This property does not affect the user agent string when
the URLRequest object is used with the
For IPv4 addresses, this is the subnet mask. Examples of the prefix length for IPv4 values include: 8 (255.0.0.0), 16 (255.255.0.0) and 24 (255.255.255.0). Example IPv6 prefix length values include 128 (::1/128) and 32 (2001:db8::/32)
Note: If the prefix length for this address is not available, the value of
By default, all capabilities are disabled, and peer-to-peer connections are allowed.
If P2P connections are disabled (you set this property to TRUE), the P2P warning dialog is suppressed. In this situation, no neighbor connections can be made, and no group members use upstream bandwidth. Disabling P2P connections in this way is generally useful only when receiving multicast streams via pure IP multicast.
A channel to the server must be opened before the server can provide supporting functions to group members. Depending on server configuration, supporting functions may or may not be provided over this channel.
AIR profile support: This feature is supported
on all desktop operating systems and on all AIR for TV devices, but is not supported on mobile devices.
You can test for support at run time using the
Note: AIR for TV devices support communication only between SWF-based content in AIR applications.
Local connections enable this kind of communication between SWF files without the use of
LocalConnection objects created in ActionScript 3.0 can communicate with LocalConnection objects created in ActionScript 1.0 or 2.0. The reverse is also true: LocalConnection objects created in ActionScript 1.0 or 2.0 can communicate with LocalConnection objects created in ActionScript 3.0. Flash Player handles this communication between LocalConnection objects of different versions automatically.
There are three ways to add callback methods to a LocalConnection object:
To understand how to use LocalConnection objects to implement communication between two files,
it is helpful to identify the commands used in each file. One file is called the receiving file;
it is the file that contains the method to be invoked. The receiving file must contain a LocalConnection object
and a call to the
Your use of
Same domain. This is the simplest way to use a LocalConnection object,
to allow communication only between LocalConnection objects that are located in the same domain,
because same-domain communication is permitted by default. When two files from the same domain communicate,
you do not need to implement any special security measures, and you simply pass the same
value for the
Different domains with predictable domain names.
When two SWF files from different domains communicate,
you need to allow communication between the two domains by calling the
Different domains with unpredictable domain names.
Sometimes, you might want to make the file with the receiving LocalConnection object
more portable between domains. To avoid specifying the domain name in the
From Flash Player to an AIR application.
A LocalConnection object created in the AIR application sandbox uses a special string as it's connection
prefix instead of a domain name. This string has the form:
Note: If an AIR application loads a SWF outside the AIR application sandbox, then the rules for establishing a local connection with that SWF are the same as the rules for establishing a connection with a SWF running in Flash Player.
From an AIR application to Flash Player.
When an AIR application communicates with a SWF running in the Flash Player runtime,
you need to allow communication between the two by calling the
From an AIR application to another AIR application.
To communicate between two AIR applications,
you need to allow communication between the two by calling the
You can use LocalConnection objects to send and receive data within a single file, but this is not a typical implementation.
For more information about the
In the LocalConnectionSenderExample SWF file, a LocalConnection instance is created,
and when the button is pressed the
In the LocalConnectionReceiverExample SWF file, a LocalConnection instance is
created and the
Note: To test the example, both SWF files must be loaded on the same computer simultaneously.
The following file sends the request to the first file.
You cannot use this method to let files hosted using a secure protocol (HTTPS) allow access from
files hosted in nonsecure protocols; you must use the
You may want to use this method so that a child file from a different domain can make LocalConnection
calls to the parent file, without knowing the final domain from which the child file will come.
This can happen, for example, when you use load-balancing redirects or third-party servers. In this situation,
you can use the
The opposite situation can also occur: you might create a child file that wants to accept LocalConnection
calls from its parent but doesn't know the domain of its parent. In this situation, implement this method by
checking whether the domain argument matches the domain of the
When using this method, consider the Flash Player security model. By default, a LocalConnection object
is associated with the sandbox of the file that created it, and cross-domain calls to LocalConnection
objects are not allowed unless you call the
For more information related to security, see the Flash Player Developer Center Topic:
Note: The
The
Calling
By default, files hosted using the HTTPS protocol can be accessed only by other files hosted using the HTTPS protocol. This implementation maintains the integrity provided by the HTTPS protocol.
Using this method to override the default behavior is not recommended, because it compromises HTTPS security. However, you might need to do so, for example, if you need to permit access to HTTPS SWF files published for Flash Player 9 or later from HTTP files SWF published for Flash Player 6 or earlier.
For more information related to security, see the Flash Player Developer Center Topic:
To avoid a race condition, define the methods attached to the receiving LocalConnection object before calling this method, as shown in the LocalConnection class example.
By default, the
In content running in the
Also by default, Flash Player lets the receiving LocalConnection object accept commands only from
sending LocalConnection objects whose connection name also resolves into a value of
If you are implementing communication only between files in the same domain, specify a string
for
If you are implementing communication between files in different domains, specifying a string
for
For more information, see the discussion in the class overview and the discussion
of
Note: Colons are used as special characters to separate the superdomain from the
When you use this method , consider the
For more information related to security, see the Flash Player Developer Center Topic:
There is a 40 kilobyte limit to the amount of data you can pass as parameters to this command.
If
As discussed in the
Note: You cannot specify a superdomain in
When you use this method , consider the
For more information related to security, see the Flash Player Developer Center Topic:
In content running in the
In SWF files published for Flash Player 9 or later, the returned string is the exact domain of
the file, including subdomains. For example, if the file is located at www.adobe.com, this command
returns
If the current file is a local file residing on the client computer running in Flash Player,
this command returns
The most common ways to use this property are to include the domain name of the sending
LocalConnection object as a parameter to the method you plan to invoke in the receiving
LocalConnection object, or to use it with
Use the NetStream class to do the following:
Note:You cannot play and publish a stream over the same NetStream object.
Adobe AIR and Flash Player 9.0.115.0 and later versions support files derived from the standard MPEG-4 container format. These files include F4V, MP4, M4A, MOV, MP4V, 3GP, and 3G2 if they contain H.264 video, HEAAC v2 encoded audio, or both. H.264 delivers higher quality video at lower bit rates when compared to the same encoding profile in Sorenson or On2. AAC is a standard audio format defined in the MPEG-4 video standard. HE-AAC v2 is an extension of AAC that uses Spectral Band Replication (SBR) and Parametric Stereo (PS) techniques to increase coding efficiency at low bit rates.
For information about supported codecs and file formats, see the following:
Receiving data from a Flash Media Server stream, progressive F4V file, or progressive FLV file
Flash Media Server, F4V files, and FLV files can send event objects containing data at specific data points during streaming or playback. You can handle data from a stream or FLV file during playback in two ways:
Wait to receive a
Note: To send data through an audio file, like an mp3 file, use the Sound class
to associate the audio file with a Sound object. Then, use the
In this example, the code that creates the Video and NetStream objects and calls the
A NetDataEvent is dispatched for the following messages:
Note: This event is not dispatched by content running in Flash Player in the browser on Android or Blackberry Tablet OS or by content running in AIR on iOS.
Note: Calls to
The
DRMStatusEvent object contains information related to the voucher, such as whether the content is available offline or when the voucher expires and users can no longer view the content.
Use the
A DRMContentData object contains the information needed to obtain a voucher required to play a DRM-protected media file. Use the DRMManager class to download the voucher with this information.
This event can return an information object with the following properties:
The associated event listener is triggered after a call to the
You can embed the following types of cue points in a video file:
The
You can define cue points in a video file when you first encode the file, or when you import a video clip in the Flash authoring tool by using the Video Import wizard.
The
Generally, to have your code respond to a specific cue point at the time it occurs, use
the
You can use the list of cue points provided to the
The associated event listener is triggered after a call to the
The onTextData event object contains one property for each piece of text data.
You need to substitute a real location to a media file with text or image
metadata for the location
You can also handle image and text data using a custom class. See the article
The associated event listener is triggered after a call to the
The onImageData event object contains the image data as a byte array sent through an AMF0 data channel.
You need to substitute a real location to a media file with text or image
metadata for the location
You can also handle image and text data using a custom class. See the article
The Flash Video Exporter utility (version 1.1 or later) embeds a video's duration, creation date, data rates, and other information into the video file itself. Different video encoders embed different sets of meta data.
The associated event listener is triggered after a call to the
In many cases, the duration value embedded in stream metadata approximates the actual duration
but is not exact. In other words, it does not always match the value of the
The event object passed to the onMetaData event handler contains one property for each piece of data.
The associated event listener is triggered after a call to the
The object passed to the
In most cases, a
If you include this parameter in your constructor statement but pass a value of
Calls to
You can also call this method to reset the byte counter for the
The byte parser understands an FLV file with a header.
After the header is parsed,
A NetStream object has two buffers: the FIFO from
Each call to
Note: The byte parser may not be able to completely decode a call to
Use this method with Flash Media Server to send live audio to the server.
Call this method before or after you call the
Set the
var nc:NetConnection = new NetConnection(); nc.connect("rtmp://server.domain.com/app"); var ns:NetStream = new NetStream(nc); var live_mic:Microphone = Microphone.get(); live_mic.rate = 8; live_mic.setSilenceLevel(20,200); var soundTrans:SoundTransform = new SoundTransform(); soundTrans.volume = 6; live_mic.soundTransform = soundTrans; ns.attachAudio(live_mic); ns.publish("mic_stream","live")
To hear the audio, call the
This method is intended for use with Flash Media Server; for more information, see the class description.
After attaching the video source, you must call
You can use
The purpose of the
For example, suppose you want to take a snapshot every 5 minutes for a total of 100 snapshots. You can do this in two ways:
Both techniques capture the same 500 frames, and both approaches are useful; the approach to use depends primarily on your playback requirements. For example, in the second case, you could be recording audio the entire time. Also, both files would be approximately the same size.
This method requires Flash Media Server version 3.5.3 or later.
To use this method to implement stream reconnection, see the
To use this method to implement load balancing, do the following:
When using Flash Media Server, this method is invoked implicitly when you call
If a peer-publisher does not implement this method, all peers are allowed to play any published content.
Starting with Flash Player 9.0.115.0, Flash Player no longer clears the buffer when
Note: For backwards compatibility, the
For a single pause, the
The
Tip: You can use
This method is an enhanced version of
Dynamic streaming
Dynamic streaming (supported in Flash Media Server 3.5 and later) lets you serve a stream encoded at multiple bit rates. As a viewer's network conditions change,
they receive the bitrate that provides the best viewing experience. Use the
Adobe built a custom ActionScript class called DynamicStream that extends the NetStream class. You can use the DynamicStream class
to implement dynamic streaming in an application instead of writing your own code to detect network conditions. Even if you choose to write your own
dynamic streaming code, use the DynamicStream class as a reference implementation. Download the class and the class documentation at the
Stream reconnecting
Stream reconnecting (supported in Flash Media Server 3.5.3 and later) lets users to experience media uninterrupted even when they lose their connection.
The media uses the buffer to play while your ActionScript logic reconnects to Flash Media Server. After reconnection, call
Play a local file
The location of a media file. Argument can be a String, a
With AIR content in the application security sandbox, the path you specify for the media file is relative to the SWF file's directory. However, you cannot navigate above the SWF file's directory. Do not specify a full path since AIR treats it as a relative path.
Play a file from Flash Media Server
You can play back the file formats described in the following table. The syntax differs depending on the file format.
Enable Data Generation Mode
To enable "Data Generation Mode", pass the value
For information about supported codecs and file formats, see the following:
Workflow for playing a file or live stream
To play a file from a local directory or web server, pass null.
To play a recorded file or live stream from Flash Media Server, pass the URI of a Flash Media Server application.
To play a live stream,
pass the stream name passed to the
To play a recorded file, pass the file name.
Note:To see sample code, scroll to the example at the bottom of this page.
Enable Data Generation Mode
Call
When you use this method without Flash Media Server, there are security considerations. A file in the local-trusted or
local-with-networking sandbox can load and play a video file from the remote sandbox, but cannot access
the remote file's data without explicit permission in the form of a URL policy file.
Use
The steps for preloading a DRM voucher include:
Create a new NetStream object for preloading the metadata.
Note: To use the same NetStream object to both preload metadata and play content,
wait for the
Downloaded vouchers are stored in a local cache. Playing content online also downloads and caches vouchers. When a DRM-protected content file is viewed, a cached voucher is retrieved from the local store automatically. Use the DRMManager to manage the voucher cache.
Notes: Preloading DRM metadata through HTTP, HTTPS, or RTMP connections is not supported. You can only preload metadata from files stored on the file system.
You can record files in the formats described in the following table (you cannot use
While publishing, you can record files in FLV or F4V format. If you record a file in F4V format,
use a flattener tool to edit or play the file in another application.
To download the tool, see
Note:Do not use this method to play a stream. To play a stream, call the
Workflow for publishing a stream
Note: A NetStream can either publish a stream or play a stream, it cannot do both. To publish a stream and view the playback from the server, create two NetStream objects. You can send multiple NetStream objects over one NetConnection object.
When Flash Media Server records a stream it creates a file.
By default, the server creates a directory with the
application instance name passed to
The following example connects to the "monday" instance of the same application. The file "lecture.flv" is recorded in the directory /applications/lectureseries/streams/monday:
To run this example, you need a camera attached to your computer. You also need to add a Button component and a Label component to the Library.
The application has a button that publishes a stream (sends it to Flash Media Server) only after
the application has successfully connected to the server. The application plays back the stream from the server
only after the stream has been successfully published. The
When you pass a value to the FPS parameter to limit the frame rate of the video, Flash Media Server attempts to reduce the frame rate while preserving the integrity of the video. Between every two keyframes, the server sends the minimum number of frames needed to satisfy the desired rate. Please note that I-frames (or intermediate frames) must be sent contiguously, otherwise the video is corrupted. Therefore, the desired number of frames is sent immediately and contiguously following a keyframe. Since the frames are not evenly distributed, the motion appears smooth in segments punctuated by stalls.
Use this method only on unicast streams that are played back from Flash Media Server. This method doesn't work on RTMFP multicast streams or when using the
The application must re-download any required vouchers from the media rights server for the user
to be able to access protected content. Calling this function is equivalent to calling the
Video streams are usually encoded with two types of frames, keyframes (or I-frames) and P-frames. A keyframe contains an entire image, while a P-frame is an interim frame that provides additional video information between keyframes. A video stream typically has a keyframe every 10-50 frames.
Flash Media Server has several types of seek behavior: enhanced seeking and smart seeking.
Enhanced seeking
Enhanced seeking is enabled by default. To disable enhanced seeking, on Flash Media Server set the
If enhanced seeking is enabled, the server generates
a new keyframe at
If enhanced seeking is disabled, the server starts streaming from the nearest keyframe. For example, suppose a video has keyframes at 0 seconds and 10 seconds. A seek to 4 seconds causes playback to start at 4 seconds using the keyframe at 0 seconds. The video stays frozen until it reaches the next keyframe at 10 seconds. To get a better seeking experience, you need to reduce the keyframe interval. In normal seek mode, you cannot start the video at a point between the keyframes.
Smart seeking
To enable smart seeking, set
Smart seeking allows Flash Player to seek within an existing back buffer and forward buffer. When smart seeking is disabled,
each time
Seeking in Data Generation Mode
When you call
You can call the
Clients who are subscribed to the live stream before a data keyframe is added receive the keyframe as soon as it is added. Clients who subscribe to the live stream after the data keyframe is added receive the keyframe when they subscribe.
To add a keyframe of metadata to a live stream sent to Flash Media Server, use
The
Use
The
This method is available only when data is streaming from Flash Media Server 3.5.3 or higher
and when
This method is intended to be used with the
If the call to
If you try to set this property to FALSE on a network protocol that does not support partial reliability, the attempt is ignored and the property is set to TRUE.
This property is available only when data is streaming from Flash Media Server 3.5.3 or higher; for more information on Flash Media Server, see the class description.
To specify how much previously displayed data is cached, use the
To prevent data from being cached, set the
This property is available only when data is streaming from Flash Media Server version 3.5.3 or later; for more information on Flash Media Server, see the class description.
Using this property improves performance for rewind operations, as data that has already been displayed isn't retrieved from the server again. Instead, the stream begins replaying from the buffer. During playback, data continues streaming from the server until the buffer is full.
If the rewind position is farther back than the data in the cache, the buffer is flushed; the data then starts streaming from the server at the requested position.
To use this property set the
When
Depending on how much playback is lagging (the difference between
Set the
The default value is 0.1 (one-tenth of a second). To determine the number of seconds
currently in the buffer, use the
To play a server-side playlist, set
Recorded content To avoid distortion when streaming pre-recorded (not live) content,
do not set the value of
Live content When streaming live content, set the
Starting with Flash Player 9.0.115.0, Flash Player no longer clears the buffer
when
For a single pause, the
The
Tip: You can use
For more information about the new pause behavior,
see
Flash Media Server. The buffer behavior depends on whether the buffer time is
set on a publishing stream or a subscribing stream.
For a publishing stream,
For a subscribing stream,
When a recorded stream is played, if
Set this property to
Do not set this property to true unless you want pixel-level access to the video you are loading. Checking for a policy file consumes network bandwidth and can delay the start of your download.
When you call the
In all cases,
If you set
If you set
Be careful with
For more information on policy files, see "Website controls (policy files)" in
the ActionScript 3.0 Developer's Guide and the Flash Player Developer Center Topic:
To associate the
When data is passed through the stream or during playback, the data event object (in
this case the
To associate the
When data is passed through the stream or during playback, the data event object (in
this case the
If you try to set this property to FALSE on a network protocol that does not support partial reliability, the attempt is ignored and the property is set to TRUE.
Flash Media Server 3.5.3 and Flash Player 10.1 work together to support smart seeking. Smart seeking uses back and forward buffers to seek without requesting data from the server. Standard seeking flushes buffered data and asks the server to send new data based on the seek time.
Call
Smart seeking reduces server load and improves seeking performance. Set
When
When a call to
This property is intended primarily for use with a server such as Flash Media Server; for more information, see the class description.
You can get the value of this property to roughly gauge the transmission quality of the stream and communicate it to the user.
If this value is not set, it defaults the limit to 60 seconds or twice the value of
Larger values can improve load balancing and fairness in the peer-to-peer mesh,
but reduce the available
The value of this property depends on whether the stream is local or
remote. Local streams, where
If you try to read this property when not connected, or if you try to change this property, the application throws an exception.
Flash Media Server For a subscribing stream, the number of seconds the stream has been playing. For a publishing stream, the number of seconds the stream has been publishing. This number is accurate to the thousandths decimal place; multiply by 1000 to get the number of milliseconds the stream has been playing.
For a subscribing stream, if the server stops sending data but the stream remains open,
the value of the
The value of
If you try to set this property to FALSE on a network protocol that does not support partial reliability, the attempt is ignored and the property is set to TRUE.
Use the NetMonitor class to get the current list of NetStream objects in use in an application. An instance of this class
dispatches a
You can use the NetMonitor class to help track video playback and related events without regard to the specific video player being used. This facility can be helpful when implementing media measurement, analytics, and usage tracking libraries.
Note: NetStream monitoring is not supported by Flash Player in the browser on Android and Blackberry Tablet OS or by AIR on iOS.
You can use the Space bar to pause and unpause the video in the example and the right and left arrows to seek forward or back 30 seconds to see the effects these actions have on the dispatched events.
Note: if the NetStream monitoring is not supported on the current platform,
Avoid caching the list of NetStream objects. Maintaining a reference to these NetStream objects can introduce memory leaks into an application by preventing the garbage collector from reclaiming an object's resources when it is no longer being used.
Note: if the NetStream monitoring is not supported on the current platform, the list returned by this function is always empty.
In recorded streaming or progressive download, if the video is a high-quality or high-resolution, high-bitrate video, the decoder can lag behind in decoding the required number of frames per second if it does not have adequate system CPU resources. In live streaming, the buffer drops video frames if the latency is too high. This property specifies the number of frames that were dropped and not presented normally.
Note: This property is always
Note: This property is always
Note: This property is always
Note: This property is always
When the message size is smaller than the maximum transmission unit (MTU), this value corresponds to the network packet loss rate.
This property returns a valid value only for RTMFP streams. For RTMP streams, it returns a value of zero.
For more information, see the
Note: This property is always
The read operations in URLStream are nonblocking.
This means that you must use the
All binary data is encoded by default in big-endian format, with the most significant byte first.
The security rules that apply to URL downloading with the URLStream class are identical to the rules applied to URLLoader objects. Policy files may be downloaded as needed. Local file security rules are enforced, and security warnings are raised as needed.
To run the example, place a file named URLStreamExample.swf in the same directory as your SWF file.
If a URLStream object registers for an
Note: If a file being loaded contains non-ASCII characters (as found in many non-English languages), it is recommended that you save the file with UTF-8 or UTF-16 encoding, as opposed to a non-Unicode format like ASCII.
If the loading operation fails immediately, an IOError or SecurityError
(including the local file security error) exception is thrown describing the failure.
Otherwise, an
By default, the calling SWF file and the URL you load must be in exactly the same domain. For example, a SWF file at www.adobe.com can load data only from sources that are also at www.adobe.com. To load data from a different domain, place a URL policy file on the server hosting the data.
In Flash Player, you cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
In Flash Player, you can prevent a SWF file from using this method by setting the
In Flash Player 10 and later, and in AIR 1.5 and later, if you use a multipart Content-Type (for example "multipart/form-data") that contains an upload (indicated by a "filename" parameter in a "content-disposition" header within the POST body), the POST operation is subject to the security rules applied to uploads:
Also, for any multipart Content-Type, the syntax must be valid (according to the RFC2046 standards). If the syntax appears to be invalid, the POST operation is subject to the security rules applied to uploads.
These rules also apply to AIR content in non-application sandboxes. However, in Adobe AIR, content in the application sandbox (content installed with the AIR application) are not restricted by these security limitations.
For more information related to security, see The Flash Player Developer Center Topic:
In AIR, a URLRequest object can register for the
If there is an
The returned value is in the range -128...127.
The returned value is in the range -2147483648...2147483647.
Note: If the value for the
The returned value is in the range -32768...32767.
The returned value is in the range 0...255.
The returned value is in the range 0...4294967295.
The returned value is in the range 0...65535.
Use shared objects to do the following:
To create a local shared object, call
When an application closes, shared objects are flushed, or written to a disk.
You can also call the
Local disk space considerations. Local shared objects have some limitations that are important to consider as you design your application. Sometimes SWF files may not be allowed to write local shared objects, and sometimes the data stored in local shared objects can be deleted without your knowledge. Flash Player users can manage the disk space that is available to individual domains or to all domains. When users decrease the amount of disk space available, some local shared objects may be deleted. Flash Player users also have privacy controls that can prevent third-party domains (domains other than the domain in the current browser address bar) from reading or writing local shared objects.
Note: SWF files that are stored and run on a local computer, not from a remote server,
can always write third-party shared objects to disk.
For more information about third-party shared objects, see the
It's a good idea to check for failures related to the amount of disk space and to
user privacy controls. Perform these checks when you call
If your SWF file attempts to create or modify local shared objects, make sure
that your SWF file is at least 215 pixels wide and at least 138 pixels high (the
minimum dimensions for displaying the dialog box that prompts users to increase their
local shared object storage limit). If your SWF file is smaller than these dimensions and an
increase in the storage limit is required,
Remote shared objects. With Flash Media Server, you can create and use remote shared objects, that are shared in real-time by all clients connected to your application. When one client changes a property of a remote shared object, the property is changed for all connected clients. You can use remote shared objects to synchronize clients, for example, users in a multi-player game.
Each remote shared object has a
You can choose to make remote shared objects persistent on the client, the server, or both. By default, Flash Player saves locally persistent remote shared objects up to 100K in size. When you try to save a larger object, Flash Player displays the Local Storage dialog box, which lets the user allow or deny local storage for the shared object. Make sure your Stage size is at least 215 by 138 pixels; this is the minimum size Flash requires to display the dialog box.
If the user selects Allow, the server saves the shared object and
dispatches a
For remote shared objects used with Flash Media Server,
Before attempting to work with a remote shared object,
first check for any errors using a
Call the
Note: Local content can always write shared objects from third-party domains (domains other than the domain in the current browser address bar) to disk, even if writing of third-party shared objects to disk is disallowed.
If this method returns
For example, if you expect a shared object to grow to a maximum size of 500 bytes, even
though it might start out much smaller, pass 500 for
After the user responds to the dialog box, this method is called again. A
~ % & \ ; : " ' , < > ? #
If your SWF file is delivered over a non-HTTPS connection and you try to set this parameter
to
The following diagram shows the use of the
The following code shows how you assign the returned shared object reference to a variable:
Note: If the user has chosen to never allow local storage for this domain,
the object is not saved locally, even if a value for
To avoid name conflicts, Flash looks at the location of the SWF file creating the
shared object. For example, if a SWF file at www.myCompany.com/apps/stockwatcher.swf creates a
shared object named
Although the
To avoid inadvertently restricting access to a shared object, use
the
When using this method, consider the following security model:
Suppose you publish SWF file content to be played back as local files (either locally installed SWF files or EXE files), and you need to access a specific shared object from more than one local SWF file. In this situation, be aware that for local files, two different locations might be used to store shared objects. The domain that is used depends on the security permissions granted to the local file that created the shared object. Local files can have three different levels of permissions:
Local files with access to the local filesystem (level 1 or 3) store their shared objects in one location. Local files without access to the local filesystem (level 2) store their shared objects in another location.
You can prevent a SWF file from using this method by setting the
For more information, see the Flash Player Developer Center Topic:
~ % & \ ; : " ' , > ? ? #
Note: If the user has chosen to never allow local storage for this domain, the object will not be saved locally, even if a local path is specified for persistence. For more information, see the class description.
To create a remote shared object, call
To confirm that the local and remote copies of the shared object are synchronized,
listen for and handle the
To create a shared object that is available only to the current client,
use
Note: Do not use a reserved term for the function names.
For example,
Call the
The
For more information about remote shared objects see the
Note: The
All attributes of a shared object's
Note: Do not assign values directly to the
To delete attributes for local shared objects, use code such as
To create private values for a shared object — values that are available only to the client
instance while the object is in use and are not stored with the object when it is closed — create properties
that are not named
The shared object contains the following data:
For remote shared objects used with a server, all attributes of the
For more information about object encoding, including the difference between
encoding in local and remote shared objects, see the description of the
The default value of
To set the object encoding on a per-object basis, rather than for all shared objects
created by the SWF file, set the
Object encoding is handled differently depending if the shared object is local or remote.
Flash calculates the size of a shared object by stepping through all of its data properties; the more data properties the object has, the longer it takes to estimate its size. Estimating object size can take significant processing time, so you may want to avoid using this method unless you have a specific need for it.
Use this method when you want to control the amount of traffic between
the client and the server. For example, if the connection between the client
and server is relatively slow, you may want to set
Setting
Changes are not sent to the server until the
Notes:
The
You can use this mode to build a playlist from scratch, or to rebuild a playlist after a lost connection is recovered.
For a new playlist, when
This transition mode is in contrast to the
In this mode, Flash Media Server queues up the stream specified in
In this mode, the currently playing stream is flushed and the stream specified in
This mode replaces the stream specified in
If
Use this mode if the streams you want to switch are not related to each other and have different content or lengths. For example, use this mode when you want to swap one commercial for another based on user tracking and past commercial-viewing statistics.
To switch from one stream to another with the same content, use the
Use this mode when you want to switch to a stream that has the same content but is encoded at a different bit rate or resolution. For example, use this mode when the application queues up streams in a playlist or is playing a single stream at a particular bit rate, then calculates that the bandwidth availability or the CPU capability is either lower or higher than the stream requirements. The application can then update the streams with their higher or lower bit rate versions.
In this mode, Flash Media Server makes certain assumptions about the relationship between the
When a playlist has been queued up and
If
To switch from one stream to another with different content, use the
For security information about loading content and data into Flash Player and AIR, see the following:
To write callback methods for this class, extend the class and define the
callback methods in the subclass, or assign the
In this example, the code that creates the Video and NetStream objects and calls the
connect()
.
If an application needs to communicate with servers released prior
to Flash Player 9, set the NetConnection object's
The following code creates a NetConnection object:
var nc:NetConnection = new NetConnection();
With Flash Media Server,
You cannot connect to commonly reserved ports. For a complete list of blocked ports, see "Restricting Networking APIs" in the ActionScript 3.0 Developer's Guide.
This method disconnects all NetStream objects running over the connection.
Any queued data that has not been sent is discarded. (To terminate
local or server streams without closing the connection, use
The
With Flash Media Server, the best development practice is to call
This connection type has the following limitations:
Only peers on the same LAN can discover each other.
Using IP multicast, Flash Player can receive streams, it cannot send them.
Flash Player and AIR can send and receive streams in a peer-to-peer group, but the peers must be discovered on the same LAN using IP multicast.
This technique cannot be used for one-to-one communication.
Use one of the following protocols:
If the file is served from the same host where the server is installed,
you can omit the
(Flash Player 10.1 or AIR 2 or later)To create peer-to-peer applications, use the
Call
Consider the following security model:
However, in Adobe AIR, content in the
For more information about security, see the Adobe Flash Player Developer Center:
The value is
The value is
The value is
The value is
The default value is
To set an object's encoding separately (rather than setting object encoding for the entire
application), set the
For more detailed information, see the description of the
This value does not distinguish between publisher and subscriber connections. If this value is reduced while peer connections are present, the new value affects new incoming connections only. Existing connections are not dropped.
Every NetConnection instance has a unique
Other Flash Player or Adobe AIR instances
use this identifier as the
When an object is written to or read from binary data, the
It's important to understand this property if your application needs to communicate with servers released prior to Flash Player 9. The following three scenarios are possible:
Once a NetConnection instance is connected, its
If you use the wrong encoding to connect to a server, the NetConnection object
dispatches the
"best"
; if this value
is not changed, native SSL sockets are used by default, and a fallback
to other methods is used if necessary.
Acceptable values are
To use native SSL, set the property to
If the property is set to
This property is applicable only when using RTMP, RTMPS, or RTMPT. The