[7849] | 1 | /*
|
---|
| 2 | Adobe Systems Incorporated(r) Source Code License Agreement
|
---|
| 3 | Copyright(c) 2005 Adobe Systems Incorporated. All rights reserved.
|
---|
| 4 |
|
---|
| 5 | Please read this Source Code License Agreement carefully before using
|
---|
| 6 | the source code.
|
---|
| 7 |
|
---|
| 8 | Adobe Systems Incorporated grants to you a perpetual, worldwide, non-exclusive,
|
---|
| 9 | no-charge, royalty-free, irrevocable copyright license, to reproduce,
|
---|
| 10 | prepare derivative works of, publicly display, publicly perform, and
|
---|
| 11 | distribute this source code and such derivative works in source or
|
---|
| 12 | object code form without any attribution requirements.
|
---|
| 13 |
|
---|
| 14 | The name "Adobe Systems Incorporated" must not be used to endorse or promote products
|
---|
| 15 | derived from the source code without prior written permission.
|
---|
| 16 |
|
---|
| 17 | You agree to indemnify, hold harmless and defend Adobe Systems Incorporated from and
|
---|
| 18 | against any loss, damage, claims or lawsuits, including attorney's
|
---|
| 19 | fees that arise or result from your use or distribution of the source
|
---|
| 20 | code.
|
---|
| 21 |
|
---|
| 22 | THIS SOURCE CODE IS PROVIDED "AS IS" AND "WITH ALL FAULTS", WITHOUT
|
---|
| 23 | ANY TECHNICAL SUPPORT OR ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
|
---|
| 24 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
---|
| 25 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. ALSO, THERE IS NO WARRANTY OF
|
---|
| 26 | NON-INFRINGEMENT, TITLE OR QUIET ENJOYMENT. IN NO EVENT SHALL MACROMEDIA
|
---|
| 27 | OR ITS SUPPLIERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
---|
| 28 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
---|
| 29 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
---|
| 30 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
---|
| 31 | WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
---|
| 32 | OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOURCE CODE, EVEN IF
|
---|
| 33 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 34 | */
|
---|
| 35 |
|
---|
| 36 | package com.adobe.webapis
|
---|
| 37 | {
|
---|
| 38 | import flash.events.IOErrorEvent;
|
---|
| 39 | import flash.events.SecurityErrorEvent;
|
---|
| 40 | import flash.events.ProgressEvent;
|
---|
| 41 |
|
---|
| 42 | import com.adobe.net.DynamicURLLoader;
|
---|
| 43 |
|
---|
| 44 | /**
|
---|
| 45 | * Dispatched when data is
|
---|
| 46 | * received as the download operation progresses.
|
---|
| 47 | *
|
---|
| 48 | * @eventType flash.events.ProgressEvent.PROGRESS
|
---|
| 49 | *
|
---|
| 50 | * @langversion ActionScript 3.0
|
---|
| 51 | * @playerversion Flash 9.0
|
---|
| 52 | */
|
---|
| 53 | [Event(name="progress", type="flash.events.ProgressEvent")]
|
---|
| 54 |
|
---|
| 55 | /**
|
---|
| 56 | * Dispatched if a call to the server results in a fatal
|
---|
| 57 | * error that terminates the download.
|
---|
| 58 | *
|
---|
| 59 | * @eventType flash.events.IOErrorEvent.IO_ERROR
|
---|
| 60 | *
|
---|
| 61 | * @langversion ActionScript 3.0
|
---|
| 62 | * @playerversion Flash 9.0
|
---|
| 63 | */
|
---|
| 64 | [Event(name="ioError", type="flash.events.IOErrorEvent")]
|
---|
| 65 |
|
---|
| 66 | /**
|
---|
| 67 | * A securityError event occurs if a call attempts to
|
---|
| 68 | * load data from a server outside the security sandbox.
|
---|
| 69 | *
|
---|
| 70 | * @eventType flash.events.SecurityErrorEvent.SECURITY_ERROR
|
---|
| 71 | *
|
---|
| 72 | * @langversion ActionScript 3.0
|
---|
| 73 | * @playerversion Flash 9.0
|
---|
| 74 | */
|
---|
| 75 | [Event(name="securityError", type="flash.events.SecurityErrorEvent")]
|
---|
| 76 |
|
---|
| 77 | /**
|
---|
| 78 | * Base class for services that utilize URLLoader
|
---|
| 79 | * to communicate with remote APIs / Services.
|
---|
| 80 | *
|
---|
| 81 | * @langversion ActionScript 3.0
|
---|
| 82 | * @playerversion Flash 9.0
|
---|
| 83 | */
|
---|
| 84 | public class URLLoaderBase extends ServiceBase
|
---|
| 85 | {
|
---|
| 86 | protected function getURLLoader():DynamicURLLoader
|
---|
| 87 | {
|
---|
| 88 | var loader:DynamicURLLoader = new DynamicURLLoader();
|
---|
| 89 | loader.addEventListener("progress", onProgress);
|
---|
| 90 | loader.addEventListener("ioError", onIOError);
|
---|
| 91 | loader.addEventListener("securityError", onSecurityError);
|
---|
| 92 |
|
---|
| 93 | return loader;
|
---|
| 94 | }
|
---|
| 95 |
|
---|
| 96 | private function onIOError(event:IOErrorEvent):void
|
---|
| 97 | {
|
---|
| 98 | dispatchEvent(event);
|
---|
| 99 | }
|
---|
| 100 |
|
---|
| 101 | private function onSecurityError(event:SecurityErrorEvent):void
|
---|
| 102 | {
|
---|
| 103 | dispatchEvent(event);
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | private function onProgress(event:ProgressEvent):void
|
---|
| 107 | {
|
---|
| 108 | dispatchEvent(event);
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | }
|
---|