Hi,
I'm trying to get flash to load PHP dynamically generated XML. The flash file should display jpg images of the thumbnails in the XML file. However when I new_release.swf is not displaying any images.
Does anyone know what mistake i'm making?
The following is my flash file:
new_release.fla
Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
//thumbnails[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].firstChild.nodeValue;
message("hello");
thumbnails_fn(i);
}
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.load("index_test_new.php");
xmlData.onLoad = loadXML;
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(eval("thumbnail_mc.t"+k)._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}
my php file:index_test_new.php
PHP Code:
<?php
header('Content-Type: application/xml');
include("c:\bookstore\db.php");
$cxn = @ConnectToDb($server, $user, $pass, $database);
$table_id = 'books';
$sql = "select title, date_format( pub_date, '%d %M %Y' ) as f_pub_date " .
"from $table_id where MONTH(pub_date)= MONTH(CURRENT_DATE) and YEAR(pub_date) = YEAR(CURRENT_DATE) ".
"order by f_pub_date desc";
$result = mysql_query($sql) or die(mysql_error());
if (mysql_num_rows($result)>0)
{ $doc = new DomDocument('1.0');
/*$root = $doc->createElement('root');
$root = $doc->appendChild($root);*/
$root = $doc->createElement($table_id);
$root = $doc->appendChild($root);
while ($row = mysql_fetch_assoc($result))
{ $child = $doc->createElement('thumbnail');
$child = $root->appendChild($child);
$title_str = str_replace(' ','_',trim(strtolower($row["title"])));
$pos = strpos($title_str,'/');
if ($pos === false){
$fileName = $title_str.'_sm'.'.jpg';
if(file_exists($fileName))
{ $value = $doc->createTextNode($fileName);
$value = $child->appendChild($value);
}//if
else
{$fileName = $title_str.'_sm'.'.gif';
if(file_exists($fileName)){
$value = $doc->createTextNode($fileName);
$value = $doc->appendChild($value);
}//if
}//else
}//if
else{
$title_str2 = str_replace('/','_',$title_str2);
$fileName = $title_str2.'_sm'.'.jpg';
if(file_exists($fileName))
{ $value = $doc->createTextNode($fileName);
$value = $doc->appendChild($value);
}
else
{$fileName = $title_str2.'_sm'.'.gif';
if(file_exists($fileName)){
$value = $doc->createTextNode($fileName);
$value = $doc->appendChild($value);
}//if
}//else
}//else
}//end while
$xml_string = $doc->saveXML();
echo $xml_string;
}//END IF STMT
XML generated by index_test_new.php
<?xml version="1.0" ?>
- <books>
<thumbnail>basic_cooking_sm.jpg</thumbnail>
<thumbnail>dessert_recipes_sm.jpg</thumbnail>
</books>
i'm not able to get rid of that hypen in red above.
thanks a lot in advance