/*---------------- FILE HEADER --------------------------------------- This file is part of Geoide. Copyright (C) 2005-2006 by: IDgis B.V. http://www.idgis.nl This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Contact: Herman Assink IDgis bv P.O. Box 15 7450 AA Holten The Netherlands E-Mail: herman.assink@idgis.nl * @version 1.4.0 * @author IDgis team * ------------------------------------------------------------------------*/ import nl.idgis.giclient.io.SWFResponseListener; import nl.idgis.giclient.util.Strings; import nl.idgis.giclient.framework.FrameWork; class nl.idgis.giclient.io.SWFResponse { static private var index:Number = 0; private var swfResponseListener:SWFResponseListener = null; private var movieClip:MovieClip = null; private var properties:Array = null; private var movieClipLoader:MovieClipLoader = null; private var removing:Boolean = false; private var intervalID = null; // For some reason intervalID cannot be given a type, not even Object. private var url:String = null; //url used in movieClipLoader.loadClip() function SWFResponse(swfResponseListener:SWFResponseListener, target:MovieClip, minDepth:Number, maxDepth:Number) { this.swfResponseListener = swfResponseListener; var name:String = "swfResponse" + index; var depth:Number = minDepth + index; index++; if ((maxDepth != null) && (depth > maxDepth)) { // EXCEPTION } else { movieClip = target.createEmptyMovieClip(name, depth); movieClipLoader = new MovieClipLoader(); movieClipLoader.addListener(this); properties = new Array(); } } function getMovieClip():MovieClip { return movieClip; } function getUrl():String { return url; } function setProperty(name:String, value:Object):Void { properties[name] = value; } function getProperty(name:String):Object { return properties[name]; } function load(url:String, initAlpha:Number):Void { // AUTHENTICATION //movieClip._alpha = initAlpha; // Setting this property to 0 in the onLoadInit would cause a flicker. That's why it is set here; before the load process. Fortunately the property is not reset in the loading process. movieClip._visible = false; this.url = url; movieClipLoader.loadClip(url, movieClip); FrameWork(_root["frameWork"]).setBusy("mapLayer", url); } function onLoadComplete(target_mc:MovieClip, httpStatus:Number) { FrameWork(_root["frameWork"]).resetBusy("mapLayer", url); } function onLoadProgress(target:MovieClip, numBytesLoaded:Number, numBytesTotal:Number) { swfResponseListener.onLoadProgressSWFResponse(this, numBytesLoaded, numBytesTotal); } function onLoadError(target:MovieClip, errorCode:Number, httpStatus:Number ) { swfResponseListener.onLoadErrorSWFResponse(this, errorCode, httpStatus); FrameWork(_root["frameWork"]).resetBusy("mapLayer", url); } function onLoadInit(target:MovieClip):Void { target._visible = false; var problems:String = movieClip.problems; if (problems != null) { // _root["frameWork"].state("The response from the Geoide connector contains problems:", 0); _root["frameWork"].state(Strings.getFile("Geoide").getString("GeoideResponseProblem"), 0); _root["frameWork"].state(problems, 0); } swfResponseListener.onLoadSWFResponse(this); } function removeSWFResponseListener():Void { swfResponseListener = null; } function removeMovieClip(intervalDuration:Number):Void { if (movieClip != null) { //if ((intervalDuration == null) || (intervalDuration < 10)) { doRemoveMovieClip(); //} else { // removing = true; //if (intervalID != null) { //clearInterval(intervalID); //} //intervalID = setInterval(this, "doFadeOut", intervalDuration); //} } } function fadeIn(intervalDuration:Number):Void { if (!removing) { //movieClip._alpha = 100; movieClip._visible = true; //if (intervalID != null) { //clearInterval(intervalID); //} //intervalID = setInterval(this, "doFadeIn", intervalDuration); } } function fadeOut(intervalDuration:Number):Void { if (!removing) { //movieClip._alpha = 0; movieClip._visible = false; //if (intervalID != null) { //clearInterval(intervalID); //} //intervalID = setInterval(this, "doFadeOut", intervalDuration); } } /*private function doFadeIn():Void { movieClip._alpha += 50; if (movieClip._alpha > 80) { movieClip._alpha = 100; clearInterval(intervalID); intervalID = null; } } private function doFadeOut():Void { movieClip._alpha -= 50; if (movieClip._alpha < 20) { movieClip._alpha = 0; clearInterval(intervalID); intervalID = null; if (removing) { doRemoveMovieClip(); removing = false; } } }*/ private function doRemoveMovieClip():Void { movieClip.removeMovieClip(); } }