03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

The following example traces the progress of a download using the onProgress event listener.<br />

import flash.net.File<strong>Reference</strong>;<br />

var listener:Object = new Object();<br />

listener.onProgress = function(file:File<strong>Reference</strong>, bytesLoaded:Number,<br />

bytesTotal:Number):Void {<br />

trace("onProgress: " + file.name + " with bytesLoaded: " + bytesLoaded +<br />

" bytesTotal: " + bytesTotal);<br />

}<br />

var fileRef:File<strong>Reference</strong> = new File<strong>Reference</strong>();<br />

fileRef.addListener(listener);<br />

var url:String = "http://www.adobe.com/platform/whitepapers/<br />

platform_overview.pdf";<br />

fileRef.download(url, "FlashPlatform.pdf");<br />

See also<br />

onComplete (File<strong>Reference</strong>.onComplete event listener)<br />

onSecurityError (File<strong>Reference</strong>.onSecurityError<br />

event listener)<br />

onSecurityError = function(fileRef:File<strong>Reference</strong>, errorString:String) {}<br />

Invoked when an upload or download fails because of a security error. The calling SWF file<br />

may have tried to access a SWF file outside its domain <strong>and</strong> does not have permission to do so.<br />

You can try to remedy this error by using a cross-domain policy file.<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 8<br />

Parameters<br />

fileRef:File<strong>Reference</strong> - The File<strong>Reference</strong> object that initiated the operation.<br />

errorString:String - Describes the error that caused onSecurityError to be called. The<br />

value is "securityS<strong>and</strong>boxError".<br />

Example<br />

The following example creates a File<strong>Reference</strong> object with a listener for each possible event,<br />

including onSecurityError. The onSecurityError listener is triggered only if the upload<br />

fails because of a security error.<br />

import flash.net.File<strong>Reference</strong>;<br />

584 <strong>ActionScript</strong> classes

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

Saved successfully!

Ooh no, something went wrong!