mas01mj@732: /* mas01mj@732: Copyright (c) 2008, Adobe Systems Incorporated mas01mj@732: All rights reserved. mas01mj@732: mas01mj@732: Redistribution and use in source and binary forms, with or without mas01mj@732: modification, are permitted provided that the following conditions are mas01mj@732: met: mas01mj@732: mas01mj@732: * Redistributions of source code must retain the above copyright notice, mas01mj@732: this list of conditions and the following disclaimer. mas01mj@732: mas01mj@732: * Redistributions in binary form must reproduce the above copyright mas01mj@732: notice, this list of conditions and the following disclaimer in the mas01mj@732: documentation and/or other materials provided with the distribution. mas01mj@732: mas01mj@732: * Neither the name of Adobe Systems Incorporated nor the names of its mas01mj@732: contributors may be used to endorse or promote products derived from mas01mj@732: this software without specific prior written permission. mas01mj@732: mas01mj@732: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS mas01mj@732: IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, mas01mj@732: THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR mas01mj@732: PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR mas01mj@732: CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, mas01mj@732: EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, mas01mj@732: PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR mas01mj@732: PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF mas01mj@732: LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING mas01mj@732: NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS mas01mj@732: SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. mas01mj@732: */ mas01mj@732: mas01mj@732: package com.adobe.webapis mas01mj@732: { mas01mj@732: import flash.events.IOErrorEvent; mas01mj@732: import flash.events.SecurityErrorEvent; mas01mj@732: import flash.events.ProgressEvent; mas01mj@732: mas01mj@732: import com.adobe.net.DynamicURLLoader; mas01mj@732: mas01mj@732: /** mas01mj@732: * Dispatched when data is mas01mj@732: * received as the download operation progresses. mas01mj@732: * mas01mj@732: * @eventType flash.events.ProgressEvent.PROGRESS mas01mj@732: * mas01mj@732: * @langversion ActionScript 3.0 mas01mj@732: * @playerversion Flash 9.0 mas01mj@732: */ mas01mj@732: [Event(name="progress", type="flash.events.ProgressEvent")] mas01mj@732: mas01mj@732: /** mas01mj@732: * Dispatched if a call to the server results in a fatal mas01mj@732: * error that terminates the download. mas01mj@732: * mas01mj@732: * @eventType flash.events.IOErrorEvent.IO_ERROR mas01mj@732: * mas01mj@732: * @langversion ActionScript 3.0 mas01mj@732: * @playerversion Flash 9.0 mas01mj@732: */ mas01mj@732: [Event(name="ioError", type="flash.events.IOErrorEvent")] mas01mj@732: mas01mj@732: /** mas01mj@732: * A securityError event occurs if a call attempts to mas01mj@732: * load data from a server outside the security sandbox. mas01mj@732: * mas01mj@732: * @eventType flash.events.SecurityErrorEvent.SECURITY_ERROR mas01mj@732: * mas01mj@732: * @langversion ActionScript 3.0 mas01mj@732: * @playerversion Flash 9.0 mas01mj@732: */ mas01mj@732: [Event(name="securityError", type="flash.events.SecurityErrorEvent")] mas01mj@732: mas01mj@732: /** mas01mj@732: * Base class for services that utilize URLLoader mas01mj@732: * to communicate with remote APIs / Services. mas01mj@732: * mas01mj@732: * @langversion ActionScript 3.0 mas01mj@732: * @playerversion Flash 9.0 mas01mj@732: */ mas01mj@732: public class URLLoaderBase extends ServiceBase mas01mj@732: { mas01mj@732: protected function getURLLoader():DynamicURLLoader mas01mj@732: { mas01mj@732: var loader:DynamicURLLoader = new DynamicURLLoader(); mas01mj@732: loader.addEventListener("progress", onProgress); mas01mj@732: loader.addEventListener("ioError", onIOError); mas01mj@732: loader.addEventListener("securityError", onSecurityError); mas01mj@732: mas01mj@732: return loader; mas01mj@732: } mas01mj@732: mas01mj@732: private function onIOError(event:IOErrorEvent):void mas01mj@732: { mas01mj@732: dispatchEvent(event); mas01mj@732: } mas01mj@732: mas01mj@732: private function onSecurityError(event:SecurityErrorEvent):void mas01mj@732: { mas01mj@732: dispatchEvent(event); mas01mj@732: } mas01mj@732: mas01mj@732: private function onProgress(event:ProgressEvent):void mas01mj@732: { mas01mj@732: dispatchEvent(event); mas01mj@732: } mas01mj@732: } mas01mj@732: }