FORUMS: list search recent posts

Convert AS2 to AS3 (PHP, XML List)

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Jesper Neergaard
Convert AS2 to AS3 (PHP, XML List)
on May 11, 2010 at 9:54:12 am

Hi,

I've followed the PHP, MySQL tutorial (http://library.creativecow.net/articles/brimelow_lee/php_mysql/video-tutorial.php) and finally got it to work - The problem was, that it has to be used in AS2.

Is there any way, to rewrite the code to work in AS3?
The code looks as follows;

var theXML:XML = new XML();
theXML.ignoreWhite = true;

theXML.onLoad = function() {
var nodes = this.firstChild.childNodes;
for(i=0;i<nodes.length;i++) {
theList.addItem(nodes[i].firstChild.nodeValue,i);
}
}
theXML.load("http://nega.dk/index.php");


Thanks!


Return to posts index

Adam Ashby
Re: Convert AS2 to AS3 (PHP, XML List)
on May 12, 2010 at 4:57:36 am

If you xml looked like this:

<items>
<item label = "one" />
<item label = "two" />
<item label = "three" />
</items>


Then:

var i:int = 0;
var xmlLoader = new URLLoader(new URLRequest("http://nega.dk/index.php"));
xmlLoader.addEventListener(Event.COMPLETE, addToList);

function addToList(e:Event):void {
var xml = new XML(xmlLoader.data);

for each (var item:XML in xml.item) {
++i;
var label:String = item.@label;
theList.addItem(label, i);
}

}


if you're not using attributes, like:

<item>one</item>

then:

var label:String = item.toString();

XML is much, much easier in AS3.



Adam Ashby
mutli-media artist
http://www.adamashby.com


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]