Log in

View Full Version : XML Flash gallery problem



windir
04-21-2009, 09:35 PM
Ok so I am loading a "portfolio.swf" into my "index.swf". I have my gallery loading my XML and it parses just fine. My problem is when I'm trying to have a preloader that is located in the _root of the index.swf, using loadMovie(image[this.id]); isn't finding the image or .swf I'm try to add to stage.

Here are some snippets of the code that I'm using in each section:

This is the portfolio.swf loading XML:


onEnterFrame = function () {
loading = (image[this.id]).getBytesLoaded();
filesize = (image[this.id]).getBytesTotal();
};
if (filesize>10) {
percentage = Math.round((loading/filesize)*100);
} else {
percentage = 0;
}
percentage = _root.preloader_mc.displayPercentage.text;

/////////////Load Category Data/////////////
images = new XML();
images.ignoreWhite = true;
images.onLoad = function(success) {
if (success) {
xmlNode = this.firstChild;
image = [];
thumb = [];
roll_over = [];
Xloc = [];
Yloc = [];
_global.desc = [];
total = xmlNode.childNodes.length;
for (var i = 0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
thumb[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
_global.desc[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
roll_over[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
Xloc[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
Yloc[i] = xmlNode.childNodes[i].childNodes[5].firstChild.nodeValue;
holder_mc.attachMovie("thumb","butj"+i,i+999);
holder_mc["butj"+i].thumb_mc._alpha = 0;
holder_mc["butj"+i].id = i;
holder_mc["butj"+i]._x = i%5*140+25;
holder_mc["butj"+i]._y = Math.floor(i/5)*90;
holder_mc["butj"+i].thumb_mc.loadMovie(thumb[i],1);
MoveNav = new Tween(holder_mc["butj"+i].thumb_mc, "_alpha", Strong.easeOut, holder_mc["butj"+i].thumb_mc._alpha, 100, 1, true);
holder_mc["butj"+i].onRollOver = function() {
MoveNav = new Tween(holder_mc["butj"+[this.id]].thumb_mc, "_alpha", Strong.easeOut, holder_mc["butj"+[this.id]].thumb_mc._alpha, 50, 0.5, true);
};
holder_mc["butj"+i].onRollOut = function() {
MoveNav = new Tween(holder_mc["butj"+[this.id]].thumb_mc, "_alpha", Strong.easeOut, holder_mc["butj"+[this.id]].thumb_mc._alpha, 100, 3, true);
};
holder_mc["butj"+i].onRelease = function() {
_global.desc[z] = _global.desc[this.id];
_global.image[1] = _global.image[this.id];
_root.big_symbol._width = Stage.width+30;
_root.big_symbol._height = Stage.height+30;
_root.big_symbol._x = 0;
_root.big_symbol._y = 0;
_root.big_symbol._visible = true;
trace(image[this.id]);
_root.preloader_mc.gotoAndStop(2);
var tweenAlphaPreloader:Tween = new Tween(_root.preloader_mc, "_alpha", Strong.easeIn, 100, 0, 1, true);
tweenAlphaPreloader.stop();
contentLoaded = function () {
tweenAlphaPreloader.start();
tweenAlphaPreloader["onMotionFinished"] = function () {

};
};


And here is what I have the preloader doing:


if (percentage == 100) {
var tweenAlphaPreloader:Tween = new Tween(_parent.preloader_mc, "_alpha", Strong.easeIn, 100, 0, 1, true);
tweenAlphaPreloader.stop();
tweenAlphaPreloader.start();
tweenAlphaPreloader["onMotionFinished"] = function () {
_parent.swfHolder.loadMovie(image[this.id]);
};
}


When I play the move like this, I'm getting "undefined" for the loadMovie.

Any help is greatly appreciated!

Medyman
04-21-2009, 11:17 PM
_parent.swfHolder.loadMovie(image[this.id]);

should probably be


_parent.swfHolder.loadMovie("portfolio.swf");

windir
04-21-2009, 11:31 PM
No, what I'm loading are items in my portfolio I want to load. They are already loading dynamically as thumbnails.

Medyman
04-21-2009, 11:37 PM
So, what you're doing is preloading the items in portfolio.swf from inside index.swf?

windir
04-21-2009, 11:51 PM
The preloader I am loading the gallery items to the holder in index.swf

Oh, I'm using the same preloader that I am to load other parts of the site. Maybe I'll just add another one to the portfolio.swf. I was try to use one for the whole site.

Medyman
04-22-2009, 01:48 PM
yeah, I have no idea what you're trying to do. It's obviously a scope issue. You're calling variables that haven't been set yet.

My question would be what do you expected the highlighted to be equal to?

_parent.swfHolder.loadMovie(image[this.id]);

windir
04-22-2009, 02:02 PM
I'm just trying to get the external swf that is clicked to load. Probably would help to post what the XML setup is. Here is a sample:



<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<Gallery/images header="PHOTO GALLERY">
<pic>
<image>portfolio_content/flash/full/1.swf</image>
<thumb>portfolio_content/flash/thumbs/1.jpg</thumb>
<description>
Here is the content
</description>
<roll_over>Picture 1</roll_over>
<Xloc>150</Xloc>
<Yloc>150</Yloc>
</pic>
</gallery>


Does that help any?