Solved

XML-script don´t  read from cache afther download.

Posted on 2010-08-27
3
293 Views
Last Modified: 2013-11-11
I have a gallery where the pictures will load with help from different  xml docs. This work, but it seems that the script download the pics from server every time even if the picture already should be in the computers cache. This slows down the user experiense. Is there anything who can be done with my script to prevent this? I will be thankful for any suggestions.


function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		image = [];
		description = [];
		description2 = [];
		total = xmlNode.childNodes.length;
		for (i=0; i<total; i++) {
			image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
			description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
			description2[i] = xmlNode.childNodes[i].childNodes[1].nextSibling.nodeValue;
			
			}
		firstImage();
	} else {
		content = "file not loaded!";
	}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images_yttertoy.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
	if (Key.getCode() == Key.LEFT) {
		prevImage();
	} else if (Key.getCode() == Key.RIGHT) {
		nextImage();
	}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
	prevImage();
};
next_btn.onRelease = function() {
	nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
	filesize = picture.getBytesTotal();
	loaded = picture.getBytesLoaded();
	preloader._visible = true;
	if (loaded != filesize) {
		preloader.preload_bar._xscale = 200*loaded/filesize;
	} else {
		preloader._visible = false;
		if (picture._alpha<100) {
			picture._alpha += 25;
		}
	}
};
function nextImage() {
	if (p<(total-1)) {
		p++;
		if (loaded == filesize) {
			picture._alpha = 0;
			picture.loadMovie(image[p], 1);
			desc_txt.text = description[p];
			desc_txt2.htmlText = description2[p];
			picture_num();
		}
	}
}
function prevImage() {
	if (p>0) {
		p--;
		picture._alpha = 0;
		picture.loadMovie(image[p], 1);
		desc_txt.text = description[p];
		desc_txt2.htmlText = description2[p];
		picture_num();
	}
}
function firstImage() {
	if (loaded == filesize) {
		picture._alpha = 0;
		picture.loadMovie(image[0], 1);
		desc_txt.text = description[0];
		desc_txt2.htmlText = description2[0];
		picture_num();
	}
}
function picture_num() {
	current_pos = p+1;
	pos_txt.text = current_pos+" / "+total;
}

Open in new window

0
Comment
Question by:toiler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Accepted Solution

by:
blue-genie earned 500 total points
ID: 33634607
it's odd, most people have the opposite problem where they don't want to load from cache.

see if this previously asked question helps
http://www.experts-exchange.com/Software/Server_Software/Web_Servers/Apache/Q_22517526.html

also make sure you're not forcing a reload everything with filename.swf?var  in your embed code



0
 

Author Comment

by:toiler
ID: 33752678
Thanks for reply blue-geni! The requierements are edited and it is a ok solution as it is.
0
 

Author Closing Comment

by:toiler
ID: 33752685
The requierements are edited and it is a ok solution as it is.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question