Flash CS3 Documentation |
|||
| ActionScript 2.0 Language Reference > ActionScript classes > Sound > checkPolicyFile (Sound.checkPolicyFile property) | |||
public checkPolicyFile : Boolean
Specifies whether Flash Player should attempt to download a cross-domain policy file from the loaded sound's server before beginning to load the sound itself. This flag is applicable to Sound.loadSound(), but not to Sound objects on which loadSound has not been called.
Set this flag to true when you are loading a sound from outside the calling SWF file's own domain and you expect to need access to the content of that sound from ActionScript. Examples of accessing sound content include referencing the Sound.id3 property to obtain MP3 metadata. If you attempt one of these operations 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 Sound.loadSound() with checkPolicyFile set to true, Flash Player does not begin downloading the sound specified in loadSound() 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 specified in loadSound(), 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 policy file provides access to the sound file by virtue of the policy file's location, and that the policy file permits access by the domain of the calling SWF file 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 loadSound(). Thus, as long as the policy file that you need exists, then as soon as you have received an onLoad event from your Sound object, 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 causes a security error.
Try to avoid setting checkPolicyFile to true if you will not be needing access to the contents of the sound 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 a sound 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 loadSound(). If the final sound file comes from a different URL because of HTTP redirects, then the initially downloaded policy file(s) might not be applicable to the sound's final URL, which is the URL that matters in security decisions.
Availability: ActionScript 2.0; Flash Player 9
Flash CS3
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flash/9.0/main/00002127.html