Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > NetStream > checkPolicyFile (NetStream.checkPolicyFile property) | |||
public checkPolicyFile : Boolean
Specifies whether Flash Player should attempt to download a cross-domain policy file from the loaded FLV file's server before beginning to load the FLV file itself. This flag is applicable when you are using a NetStream for progressive video download (standalone FLV files), but not when you are using a NetStream to obtain an RTMP asset.
Set this flag to true when you are loading an FLV video file from outside the calling SWF file's own domain and you expect to access the content of that image using BitmapData.draw(). If you attempt this operation without having specified checkPolicyFile at loading time, you may encounter a security error because the needed policy file has not been downloaded yet.
When you call NetStream.play() with checkPolicyFile set to true, Flash Player does not begin downloading the object specified in your call to play() until it has either successfully downloaded a relevant cross-domain policy file or discovered that no such policy file exists. Flash Player first considers policy files that have already been downloaded, then attempts to download any pending policy files specified in calls to System.security.loadPolicyFile(), then attempts to download a policy file from the default location that corresponds to the URL you passed to play(), which is /crossdomain.xml on the same server as that URL. In all cases, Flash Player requires that the given policy file exists on its server, that the file provides access to the object at the URL you passed to play() by virtue of the policy file's location, and that the file permits access by the domain of the calling SWF by virtue of one or more <allow-access-from> tags.
If you set checkPolicyFile to true, Flash Player waits until policy file completion to begin the main download that you specify in play(). Thus, as long as the policy file that you need exists, as soon as you have received any onMetaData or onStatus events from your NetStream, the policy file download is complete and you can safely begin performing operations that require the policy file.
If you set checkPolicyFile to true, and no relevant policy file is found, you do not receive any error indication until you attempt an operation that throws a SecurityError exception.
Try to avoid setting checkPolicyFile to true if you will not be needing pixel-level access to the video that you are loading. Checking for a policy file in this case is wasteful because it may delay the start of your download and may consume network bandwidth unnecessarily.
Be careful with checkPolicyFile if you are downloading an FLV file from a URL that may use server-side HTTP redirects. Flash Player always attempts to retrieve policy files that correspond to the initial URL that you specify in NetStream.play(). If the final FLV file comes from a different URL because of HTTP redirects, then the initially downloaded policy file(s) might not be applicable to the FLV file's final URL, which is the URL that matters in security decisions.
Availability: ActionScript 2.0; Flash Player 9
Flash CS3