Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)

Reply
 
Thread Tools Rating: Thread Rating: 4 votes, 1.00 average. Display Modes
Old 06-20-2003, 12:51 AM   #1
padnpen
Buzzed off Mt. Dew
 
Join Date: Jun 2003
Location: Newport Beach, CA
Posts: 240
Send a message via Yahoo to padnpen
Default XML Simple Array

Because I am working on this and others are probably curious too... I found a well explained example that should help you get your XML data put together perfectly... if you are unfortunate enough to be working with XML.

http://proto.layer51.com/d.aspx?f=611
padnpen is offline   Reply With Quote
Old 06-20-2003, 01:15 AM   #2
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

There are also several others in this forum, search on XML and you shall find some of them with enough persistence.
freddycodes is offline   Reply With Quote
Old 06-20-2003, 01:39 AM   #3
padnpen
Buzzed off Mt. Dew
 
Join Date: Jun 2003
Location: Newport Beach, CA
Posts: 240
Send a message via Yahoo to padnpen
Default

Yeah, hopefully fellow users of this forum will find your XML parser and find it perfect for their needs. The code that you supplied could probably fetch a dollar or two from what I have seen elsewhere.

Unfortunately, it was just a bit over my head and despite my efforts could not get to work for me. I think I may have offended you too because I never got much help figuring it out.

But this link gives a lot of information and even provides an example use that explains things in great depth. Hopefully someone trying to figure out the whole Flash/XML thing can use your information as well as the info supplied at this link to get things working for them.

BTW, I still don't have it up and running for me but it's starting to come around I think. That is probably what you need to do anyways... bash your head into the monitor long enough that things start to become clear. Kinda like beer goggles... but not.
padnpen is offline   Reply With Quote
Old 06-20-2003, 01:51 AM   #4
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

No you couldn't have offended me, but possibly my ADD made me forget about the post. What thread was that in, maybe I can look at it again. But hurry because I might forget we had this conversation in say, an hour
freddycodes is offline   Reply With Quote
Old 06-20-2003, 02:01 AM   #5
padnpen
Buzzed off Mt. Dew
 
Join Date: Jun 2003
Location: Newport Beach, CA
Posts: 240
Send a message via Yahoo to padnpen
Default

I'm hurrying, I'm hurrying. Actually, there have been a couple times when I kinda got left hanging... I figure that's just part of the forums though, taking kindness when you can get it.

http://www.actionscript.org/forums/s...threadid=29548

http://www.actionscript.org/forums/s...threadid=29552
padnpen is offline   Reply With Quote
Old 06-20-2003, 02:14 AM   #6
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Well for the first one, this is getting a little crazy, but I think its working properly. I think it adds one too many levels of complexity though.

ActionScript Code:
cXML = new XML(); cXML.ignoreWhite = true; cXML.onLoad = function(s) {     if(s) {         parseMe(this);          } }; cXML.load("CyanMenu.xml"); function parseMe(obj) {     objName = obj.firstChild.nodeName;     _root[objName] = [];     total = obj.firstChild.childNodes.length;     traverseNode(obj.firstChild, _root[objName]); } function traverseNode(node, ref) { //Returns Object     cnt++;     node = node.childNodes;     for(var i=0;i<node.length;i++) {         var tmpObj = {};         var foo = node[0].nodeName;         tmpObj[foo] = {};         tmpObj[foo].attributes = node[i].attributes;         if(node[i].childNodes[0].nodeType == 3) {             tmpObj[foo][node[i].nodeName] = {};             tmpObj[foo][node[i].nodeName] = node[i].firstChild.nodeValue;             ref.push(tmpObj);            }         else if(node[i].hasChildNodes() && node[i].childNodes[0].nodeType != 3) {             tmpObj[foo][node[i].childNodes[0].nodeName] = [];             ref.push(tmpObj);                traverseNode(node[i], tmpObj[foo][node[i].childNodes[0].nodeName]);          }         else {             ref.push(tmpObj);            }     }     if(cnt == total) {         trace ("Parsing finsihed");          //Do soemthing         trace (_root.menu[0].item.subItem[0].subItem.subItem[0].subItem.subItem[0].subItem.attributes.label);     } }

The xml
Code:
<?xml version="1.0" ?>
<menu>
	<item label="Programs" type="Folder">
		<subItem label="Accessaries" type="Folder">
			<subItem label="Accessibility" type="Folder">
				<subItem label="Etc1" type="Menu"/>
				<subItem label="Etc2" type="Menu"/>
            </subItem>
			<subItem label="Communications" type="Folder"/>
			<subItem label="Entertainment" type="Folder"/>
			<subItem label="Games" type="Folder"/>
			<subItem label="System Tools" type="Folder"/>
			<subItem label="Calculator" type="Menu"/>
			<subItem label="Command Prompt" type="Menu"/>
			<subItem label="Imaging" type="Menu"/>
			<subItem label="NotePad" type="Menu"/>
			<subItem label="Paint" type="Menu"/>
			<subItem label="WordPad" type="Menu"/>
		</subItem>
		<subItem label="Administrative Tools" action="String">
			<subItem label="Component Services" type="Menu"/>
			<subItem label="Computer Management" type="Menu"/>
			<subItem label="Data Sources (ODBC)" type="Menu"/>
			<subItem label="Event Viewer" type="Menu"/>
			<subItem label="Internet Services Manager" type="Menu"/>
			<subItem label="Local Security Policy" type="Menu"/>
			<subItem label="Microsoft .NET Framework Configuration" type="Menu"/>
			<subItem label="Microsoft .NET Framework Wizards" type="Menu"/>
			<subItem label="Performance" type="Menu"/>
			<subItem label="Personal Web Manager" type="Menu"/>
			<subItem label="Server Extensions Administrator" type="Menu"/>
			<subItem label="Services" type="Menu"/>
			<subItem label="Telnet Server Administration" type="Menu"/>
		</subItem>
		<subItem label="Communication" action="String"/>
		<subItem label="Graphics" action="String"/>
		<subItem label="Utilities" action="String"/>
	</item>
	<item label="Documents" type="Menu"/>
	<item label="Settings" type="Folder">
		<subItem label="Control Panel" action="String"/>
		<subItem label="Network and Dialup Connections" action="String"/>
		<subItem label="Printers" action="String"/>
		<subItem label="Taskbar &amp; Startmenu"/>
	</item>
	<item label="Search" type="Folder">
		<subItem label="INFORMATION"/>
		<subItem label="BOOKINGS"/>
	</item>
	<item label="Contact" type="Folder">
		<subItem label="For Files or Folders..."/>
		<subItem label="On the Internet..."/>
		<subItem label="Using Microsoft Outlook..."/>
		<subItem label="For People..."/>
	</item>
	<item label="Run..." type="Menu"/>
	<item label="Shut Down..." type="Menu"/>
</menu>
freddycodes is offline   Reply With Quote
Old 06-20-2003, 02:16 AM   #7
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Hold ON Hold On, I think this one is much better.

ActionScript Code:
cXML = new XML(); cXML.ignoreWhite = true; cXML.onLoad = function(s) {     if(s) {         parseMe(this);          } }; cXML.load("CyanMenu.xml"); function parseMe(obj) {     objName = obj.firstChild.nodeName;     _root[objName] = {};     _root[objName][obj.firstChild.childNodes[0].nodeName] = [];         total = obj.firstChild.childNodes.length;     traverseNode(obj.firstChild.childNodes, _root[objName][obj.firstChild.childNodes[0].nodeName]); } function traverseNode(node, ref) { //Returns Object     cnt++;     for(var i=0;i<node.length;i++) {         var tmpObj = {};         tmpObj.attributes = node[i].attributes;         if(node[i].childNodes[0].nodeType == 3) {             tmpObj[node[i].nodeName] = {};             tmpObj[node[i].nodeName] = node[i].firstChild.nodeValue;             ref.push(tmpObj);            }         else if(node[i].hasChildNodes() && node[i].childNodes[0].nodeType != 3) {             tmpObj[node[i].childNodes[0].nodeName] = [];             ref.push(tmpObj);                traverseNode(node[i].childNodes, tmpObj[node[i].childNodes[0].nodeName]);            }         else {             ref.push(tmpObj);            }     }     if(cnt == total) {         trace ("Parsing finsihed");          //Do soemthing         trace (_root.menu.item[0].subItem[1].attributes.label);     } }
freddycodes is offline   Reply With Quote
Old 06-20-2003, 02:19 AM   #8
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

Oh sorry one more time, to account for actual node values instead of merely attributes

ActionScript Code:
cXML = new XML(); cXML.ignoreWhite = true; cXML.onLoad = function(s) {     if(s) {         parseMe(this);          } }; cXML.load("CyanMenu.xml"); function parseMe(obj) {     objName = obj.firstChild.nodeName;     _root[objName] = {};     _root[objName][obj.firstChild.childNodes[0].nodeName] = [];         total = obj.firstChild.childNodes.length;     traverseNode(obj.firstChild.childNodes, _root[objName][obj.firstChild.childNodes[0].nodeName]); } function traverseNode(node, ref) { //Returns Object     cnt++;     for(var i=0;i<node.length;i++) {         var tmpObj = {};         tmpObj.attributes = node[i].attributes;         if(node[i].childNodes[0].nodeType == 3) {             tmpObj.value = node[i].firstChild.nodeValue;             ref.push(tmpObj);            }         else if(node[i].hasChildNodes() && node[i].childNodes[0].nodeType != 3) {             tmpObj[node[i].childNodes[0].nodeName] = [];             ref.push(tmpObj);                traverseNode(node[i].childNodes, tmpObj[node[i].childNodes[0].nodeName]);            }         else {             ref.push(tmpObj);            }     }     if(cnt == total) {         trace ("Parsing finsihed");          //Do soemthing         trace (_root.menu.item[0].subItem[0].subItem[0].subItem[0]);     } }

Code:
<?xml version="1.0" ?>
<menu>
	<item label="Programs" type="Folder">
		<subItem label="Accessaries" type="Folder">
			<subItem label="Accessibility" type="Folder">
				<subItem label="Etc1" type="Menu">foo</subItem>
				<subItem label="Etc2" type="Menu"/>
            </subItem>
			<subItem label="Communications" type="Folder"/>
			<subItem label="Entertainment" type="Folder"/>
			<subItem label="Games" type="Folder"/>
			<subItem label="System Tools" type="Folder"/>
			<subItem label="Calculator" type="Menu"/>
			<subItem label="Command Prompt" type="Menu"/>
			<subItem label="Imaging" type="Menu"/>
			<subItem label="NotePad" type="Menu"/>
			<subItem label="Paint" type="Menu"/>
			<subItem label="WordPad" type="Menu"/>
		</subItem>
		<subItem label="Administrative Tools" action="String">
			<subItem label="Component Services" type="Menu"/>
			<subItem label="Computer Management" type="Menu"/>
			<subItem label="Data Sources (ODBC)" type="Menu"/>
			<subItem label="Event Viewer" type="Menu"/>
			<subItem label="Internet Services Manager" type="Menu"/>
			<subItem label="Local Security Policy" type="Menu"/>
			<subItem label="Microsoft .NET Framework Configuration" type="Menu"/>
			<subItem label="Microsoft .NET Framework Wizards" type="Menu"/>
			<subItem label="Performance" type="Menu"/>
			<subItem label="Personal Web Manager" type="Menu"/>
			<subItem label="Server Extensions Administrator" type="Menu"/>
			<subItem label="Services" type="Menu"/>
			<subItem label="Telnet Server Administration" type="Menu"/>
		</subItem>
		<subItem label="Communication" action="String"/>
		<subItem label="Graphics" action="String"/>
		<subItem label="Utilities" action="String"/>
	</item>
	<item label="Documents" type="Menu"/>
	<item label="Settings" type="Folder">
		<subItem label="Control Panel" action="String"/>
		<subItem label="Network and Dialup Connections" action="String"/>
		<subItem label="Printers" action="String"/>
		<subItem label="Taskbar &amp; Startmenu"/>
	</item>
	<item label="Search" type="Folder">
		<subItem label="INFORMATION"/>
		<subItem label="BOOKINGS"/>
	</item>
	<item label="Contact" type="Folder">
		<subItem label="For Files or Folders..."/>
		<subItem label="On the Internet..."/>
		<subItem label="Using Microsoft Outlook..."/>
		<subItem label="For People..."/>
	</item>
	<item label="Run..." type="Menu"/>
	<item label="Shut Down..." type="Menu"/>
</menu>
freddycodes is offline   Reply With Quote
Old 06-20-2003, 03:13 AM   #9
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Hehe... I love to my name mentioned alot here...

I especially love this word... 'cXML'... Don't I look like something special???
Maybe I'll need to create another nick with it...

Thanks for sharing great information, guys... Much appreciated...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 06-20-2003, 03:15 AM   #10
freddycodes
Master of Nothing
 
Join Date: Dec 2002
Location: San Diego, CA
Posts: 2,468
Default

How the hell else am I supposed to remember what a .fla does unless I name it something like CyanMenu.fla

freddycodes is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
loading an object from an array NateVeronica ActionScript 2.0 1 03-30-2004 10:53 PM


All times are GMT. The time now is 11:57 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.