Hi Guys,
I am trying to load a php that outputs xml data from a database. It then calls a function to display the thumbnails. For some reason I can’t get the php file to load. Can anyone help. I have ziped the file up. I have spent all day looking at the code and cant figure out why its not working. Thanks heaps
D
Pier25
June 3, 2008, 10:45am
2
Are you enconding the xml in UTF8?
I’m not sure
I’m including this in the xml output
<?xml version=“1.0” ?>
Still didn’t fix it.
Below is the code I am using:
Thumbs = function () {
this.__init__ ();
};
Thumbs.prototype = new MovieClip ();
// ** init class ** //
Thumbs.prototype.__init__ = function () {
this._xscale = 100
this._yscale = 100
//this._thumbs_.unloadMovie()
this._dataProvider = new Array ();
this._count = 0;
this._depth = 1;
this._isLoaded = -1;
if (this._S_) {
clearInterval (this._S_);
}
this._xmlfile='get_category_index.php';
if (this._xmlfile != "") {
this.loadPHPXML (this._xmlfile);
}
};
Thumbs.prototype.loadPHPXML = function (x) {
var _xml = new XML();
_xml.ignoreWhite = true;
_xml.path = this;
_xml.load (x);
_xml.onLoad = function () {
trace(this.firstChild.childNodes.length);
for (var i=0; i< this.firstChild.childNodes.length; i++) {
var _categoryName = this.firstChild.childNodes*.attributes.catname;
var _catID = this.firstChild.childNodes*.attributes.catid;
var _img = this.firstChild.childNodes*.firstChild.nodeValue;
this._dataProvider.push ({img:_img, categoryName:_categoryName, catID:_catID});
};
delete this;
};
this.selectThumbs();
trace(this._dataProvider.length);
}
Thumbs.prototype.selectThumbs = function (first) {
trace(this._dataProvider.length);
for (var i = 0; i<this._dataProvider.length; i++) {
//for (var i = 0; i<3; i++) {
// set variables - you can adjust gap and columns
//this.thumbMC._alpha = 100;
var name = i;
var gap = 50;
var columns = 3;
var startx = 0;
var starty = 0;
var w = this.thumbMC._width;
var h = this.thumbMC._height;
var x = (i%columns)*(w+gap);
var y = (Math.floor(i/columns))*(h+gap);
// duplicate button
this.thumbMC.duplicateMovieClip(name, i,this.getNextHighestDepth());
// position button
this[name]._x = x+startx;
this[name]._y = y+starty;
// load image
this[name].imageMC.loadMovie("gallery/"+this._dataProvider*.img);
// when clicked
this[name].onRelease = function() {
trace(image[this._name]);
//Object.Main.containerMC.loadPic(image[this._name],theGallery, this.j);
// this._alpha = 50;
};
};
// hide the thumbMC (original)
this.thumbMC._visible = false;
}
Thumbs.prototype.isLoaded = function (num) {
this._isLoaded = num;
};
Object.registerClass ("Thumbs", Thumbs);
And below is the code in the php file
include("conf.php");
$qr = mysql_query("SELECT * FROM photo_category WHERE parentID=0",$server); echo mysql_error();
$nrows = mysql_num_rows($qr);
$nl = "
";
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" . $nl;
echo "<ROOT>".$nl;
for ($i=0; $i < $nrows; $i++) {
$row = mysql_fetch_array($qr);
echo "<imageUrl catname=\"".$row['name']."\" catid=\"".$row['ID']."\"><![CDATA[".$row['image_url']."]]></imageUrl>".$nl;
}
echo "</ROOT>" . $nl;
Thanks
Daniel
Hey, I figured it out… thanks anyway.