View Single Post
Old 03-23-2009, 08:53 PM   PM User | #1
alobarn
New to the CF scene

 
Join Date: Mar 2009
Posts: 5
Thanks: 1
Thanked 0 Times in 0 Posts
alobarn is an unknown quantity at this point
How can i detect null array values??

Hi all.

I am new at flash action script and i have been trying to write a code for an island guide. I have all my data in an XML and I am trying to parse them in flash. Everything is ok with the texts but i have a problem with an arry variable that i have for the filepath of the photos that will be used for each island...

I found a "photo holder" script from "flashmo" and i modded it for my case and I am trying to determine the length of the array so that it only brings up as many "photo holders" as the picture paths given in the XML. But i can't seem to distiguish between the filled "ISLAND_PHOTO" atributes of the XML and the empty ones... I have tried "!=null", "!=undefined", even deliberately puting in some text to dermine the empty ones like "empty" and then trying a "!="emtpy"" or any other text or number but still i can not seperate them...

here is the XML "about.xml":


Code:
<?xml version="1.0" encoding="utf8"?>
<ABOUT>
	<ISLAND>
		<ISLAND_NAME>Myconos</ISLAND_NAME>
		<ISLAND_DESCR>descr descr descr</ISLAND_DESCR>
		<ACTIVITIES>something something something</ACTIVITIES>
		<EXCURSIONS>bla bla bla</EXCURSIONS>
		<ISLAND_PHOTOS>
			<ISLAND_PHOTO>\MYCONOS\MYC_PIC_1.JPG</ISLAND_PHOTO>
			<ISLAND_PHOTO>\MYCONOS\MYC_PIC_2.JPG</ISLAND_PHOTO>
			<ISLAND_PHOTO>\MYCONOS\MYC_PIC_3.JPG</ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
			<ISLAND_PHOTO></ISLAND_PHOTO>
		</ISLAND_PHOTOS>
	</ISLAND>
</ABOUT>

and the part of the script that i have a problem with:


Code:
var xml_file:String = "about.xml";
var folder:String = "thumbnails/";
var MY_PIC:Array = new Array();
var total:Number;
var i:Number;
var xml:XML = new XML();
xml.onLoad = function() {
	item_list.fm_item._visible = false;
	var nodes = this.firstChild.firstChild.lastChild.childNodes;
	total = nodes.length;

	for (i=0; i<total; i++) {
		if (nodes[i] != null); 
		{
			MY_PIC[i] = nodes[i].childNodes;
		}
	}

	create_item_list();
};
xml.load(xml_file);
xml.ignoreWhite = true;

function create_item_list():Void {
	for (i=0; i<MY_PIC.length; i++) {
		var item = flashmo_item.duplicateMovieClip("fm_item"+i, i);
		item.fm_pic.loadMovie(folder+MY_PIC[i]);
		item._x = i*320;

	}
The script should just dublicate a "photo holder" (actually called "fm_item" in the script) function for as many times as the MY_PIC.length... but that is allways 10.. as many as I have reserved in the XML... The script reads them all as not null... It works fine for the 3 paths that are defined and gives me an output of :


Code:
Error opening URL 'file:///C|/Users/user/Desktop/thumbnails/'

for the "ISLAND_PHOTO" atributes that don't have a path in them.

Any help would be greatly apricated... I have been looking at that script and trying out different solutions for a few days now, and i am not any closer to making it work the way i want it to...

Last edited by alobarn; 03-25-2009 at 06:29 PM.. Reason: rephrasing
alobarn is offline   Reply With Quote