PDA

View Full Version : load xml only once ?


henkep
05-15-2005, 03:55 PM
I has a class called Map.as. That class read a XML-file and draw the map.
This Map-class is a movieclip on the stage.
Everytime I have to "load" and "read" coordinates in the file, how do I do to avoid this. And just "draw" the map. I have send the code also


class Map extends MovieClip {

function Map() {
zoomFactor = 1000;
loadmap();
Key.addListener(this);
}
function Zoomin():Void {
clear();
zoomFactor = zoomFactor+100;
loadmap();
}
function Zoomout():Void {
clear();
zoomFactor = zoomFactor-100;
loadmap();
}

private function loadmap() {
var contryIndex:Number;
var mapIndex:Number;
var map:XML = new XML();
var X:Number;
var Y:Number;
var mapMax:Number;
var contryMax:Number;
var factor:Number;
factor = zoomFactor;
mapIndex = 0;
contryIndex = 0;
map.ignoreWhite = true;
map.load("http://localhost/GronlandXMLstereo.xml");
map.onLoad = function(success) {
if (success) {
read and draw the map
}
}
};
}


private var zoomFactor;
}

Xeef
05-15-2005, 04:04 PM
store the Map in a variable onLoad
after it if you need the map (or in general) check the variable if it's set then the map is already loaded
so use the variable instead to reload

henkep
05-19-2005, 09:31 AM
Can you show me some code ?
I donīt have the experience of flash to know what you talking about.

Henrik