Hi lot!
I have been working on a site of mine, and I wanted to make a 360 rotation view thing with some pictures (12 shots all from different angels around the same axis). I need to make a preloader load everything up front, so there wont be any legging.
My best guess was making a slide show kinda thing, with an rotation and zoom bar. And before the slide show, a frame that holds the preloader. But the preloader doesn’t loads the right images. I load my images from an XML file, and then parse them into an array (something I got from here I believe). That parts seems to work all fine, but when I load the images using a “container.loadMovie(image*);” code, it isnt loading anything, except for an error :s
Here is the code:
Frame 1 : Preloader/ XML parser;
stop();
var p = 0;
trace (p)
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
totali = xmlNode.childNodes.length;
for (i=0; i<totali; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
Preloading();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
function Preloading() {
trace(image[p])
var pic = image[0];
trace(pic)
container._alpha = 0;
container.loadMovie(image[p]);
preloader();
}
function preloader() {
total = container.getBytesTotal();
loaded = container.getBytesLoaded();
if (loaded != total) {
preloader1._visible = true;
preloader1.preload_mask._xscale = 100*loaded/filesize;
} else {
if (p<totali) {
p++;
Preloading();
} else {
p = 0;
preloader1._visible = false;
container._alpha = 100;
gotoAndPlay(2);
}
}
}
Frame 2 : Slideshow
stop();
delay = 500;
this.onEnterFrame = function() {
slideshow();
};
function slideshow() {
MyInterval = setInterval(slide, delay);
function slide() {
clearInterval(MyInterval);
if (p<totali) {
nextslide();
} else {
slide0();
}
}
}
function nextslide() {
container.loadMovie(image[p]);
slideshow();
}
function slide0() {
container.loadMovie(image[0]);
slideshow();
}
btn1.onPress = function() {
gotoAndPlay(3);
};
There are some loose ends (like the gotoAndPlay(3) things, but that is because I may wanted to add a thumbnail gallery in frame 3…
)
Do you see my error? Or is the whole code just a piece of cr*p ? Well let me know will ya? 