13.08.2012 Views

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

ACTIONSCRIPT 3 Developer’s Guide en

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>ACTIONSCRIPT</strong> 3.0 DEVELOPER’S GUIDE<br />

Security<br />

Accessing bitmap data<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The draw() and drawWithQuality() (Flash Player 11.3; AIR 3.3) methods of a BitmapData object lets you draw the<br />

curr<strong>en</strong>tly displayed pixels of any display object to the BitmapData object. This could include the pixels of a MovieClip<br />

object, a Bitmap object, or any display object. The following conditions must be met for these methods to draw pixels<br />

to the BitmapData object:<br />

In the case of a source object other than a loaded bitmap, the source object and (in the case of a Sprite or MovieClip<br />

object) all of its child objects must come from the same domain as the object calling the draw method, or they must<br />

be in a SWF file that is accessible to the caller by having called the Security.allowDomain() method.<br />

In the case of a Loaded bitmap source object, the source object must come from the same domain as the object<br />

calling the draw method, or its source server must include a URL policy file that grants permission to the calling<br />

domain.<br />

If these conditions are not met, a SecurityError exception is thrown.<br />

Wh<strong>en</strong> you load the image using the load() method of the Loader class, you can specify a context parameter, which<br />

is a LoaderContext object. If you set the checkPolicyFile property of the LoaderContext object to true, Flash Player<br />

checks for a URL policy file on the server from which the image is loaded. If there is a policy file, and the file permits<br />

the domain of the loading SWF file, the file is allowed to access data in the Bitmap object; otherwise, access is d<strong>en</strong>ied.<br />

You can also specify a checkPolicyFile property in an image loaded via an tag in a text field. For details, see<br />

“Loading SWF files and images using the tag in a text field” on page 1050.<br />

Accessing sound data<br />

Flash Player 9 and later, Adobe AIR 1.0 and later<br />

The following sound-related ActionScript 3.0 APIs have security restrictions:<br />

The SoundMixer.computeSpectrum() method—Always permitted for code running in the same security<br />

sandbox as the sound file. For code running in other sandboxes, there are security checks.<br />

The SoundMixer.stopAll() method—Always permitted for code running in the same security sandbox as the<br />

sound file. For files in other sandboxes, there are security checks.<br />

The id3 property of the Sound class—Always permitted for SWF files that are in the same security sandbox as the<br />

sound file. For code running in other sandboxes, there are security checks.<br />

Every sound has two kinds of sandboxes associated with it—a cont<strong>en</strong>t sandbox and an owner sandbox:<br />

The origin domain for the sound determines the cont<strong>en</strong>t sandbox, and this determines whether data can be<br />

extracted from the sound via the id3 property of the sound and the SoundMixer.computeSpectrum() method.<br />

The object that started the sound playing determines the owner sandbox, and this determines whether the sound<br />

can be stopped using the SoundMixer.stopAll() method.<br />

Wh<strong>en</strong> you load the sound using the load() method of the Sound class, you can specify a context parameter, which<br />

is a SoundLoaderContext object. If you set the checkPolicyFile property of the SoundLoaderContext object to true,<br />

the runtime checks for a URL policy file on the server from which the sound is loaded. If there is a policy file, and the<br />

file permits the domain of the loading code, the code is allowed to access the id property of the Sound object;<br />

otherwise, it will not. Also, setting the checkPolicyFile property can <strong>en</strong>able the SoundMixer.computeSpectrum()<br />

method for loaded sounds.<br />

Last updated 6/6/2012<br />

1055

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!