Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Attributes From XML Nodes



Just a quick question:Is there anyway to get the number of attributes an xml node has. I'm just not fond of the way you have to loop through an xml node alahttp://www.macromedia.com/devnet/fla...xmlobject.html for (attr in this.childNodes[i].attributes) {...} Is there nothing like childNodes[i].attributes.length??? cheers, Rich - These smilies crack me up



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-21-2006, 12:12 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Getting Attributes Out Of My XML Nodes
Hi all -

I'm currently learning about getting XML into flash and need a little bit of help with gaining access to the attributes of an xml node.

For example

Code:
<root name="root_node">
<section name="Education">
</section>
<section name="Subscriptions">
</section>
<section name="Universities" DoNotIncludeInFlash="true">
</section>
</root>


I want to do a couple of things.
1) First get to the child node of the root node.
2) Then go through each <section> node and get it's attributes and find the name attribute and store it in a variable
3) Finally if it comes across an attribute DoNotIncludeInFlash then not to include that nodes name attribute.

I can do it if it is one node by itself, but I cannot create a syntactically correct FOR loop in order to go through all the sibling <section> nodes.

Any ideas anyone?

many thanks
frank

Loading XML Child Nodes Attributes In A Array In Flash Actionscript
hi guys .i want to load all the attributes by the name "pagename" within this xml file into an array : my_array
pls help.

xml file:

Code:

<?xml version="1.0" encoding="UTF-8" ?>
- <earnvaluemanagement>
- <module id="01" title="Overview" foldername="content/module_01">
- <chapter id="01_01" title="Introduction">
<page id="01_01_01" title="Introduction" pagename="m01_c01_p01.swf" />

<page id="01_01_02" title="Introduction" pagename="m01_c01_p02.swf" />

<page id="01_01_03" title="Introduction" pagename="m01_c01_p03.swf" />

<page id="01_01_04" title="Introduction" pagename="m01_c01_p04.swf" />

</chapter>


</module>


- <module id="02" title="Earned Value Management Concepts" foldername="content/module_02">
- <chapter id="02_01" title="Overview">
<page id="02_01_01" title="Overview" pagename="m02_c01_p01.swf" />

<page id="02_01_02" title="Overview" pagename="m02_c01_p02.swf" />

<page id="02_01_03" title="Overview" pagename="m02_c01_p03.swf" />

<page id="02_01_04" title="Overview" pagename="m02_c01_p04.swf" />

<page id="02_01_05" title="Overview" pagename="m02_c01_p05.swf" />

<page id="02_01_06" title="Overview" pagename="m02_c01_p06.swf" />

</chapter>


- <chapter id="02_02" title="Framework of EVM System">
<page id="02_02_07" title="Framework of EVM System" pagename="m02_c01_p07.swf" />

<page id="02_02_08" title="Framework of EVM System" pagename="m02_c01_p08.swf" />

<page id="02_02_09" title="Framework of EVM system" pagename="m02_c01_p09.swf" />

<page id="02_02_10" title="Framework of EVM system" pagename="m02_c01_p10.swf" />

<page id="02_02_11" title="Exercise" pagename="m02_c01_p11_exercise01.swf" />

<page id="02_02_12" title="Exercise" pagename="m02_c01_p11_exercise02.swf" />

<page id="02_02_13" title="Summary" pagename="m02_c01_p12_Summary.swf" />

</chapter>


</module>


- <module id="03" title="Scope of the Project: Work Breakdown Structure" foldername="content/module_03">
- <chapter id="03_01" title="What is WBS?">
<page id="03_01_01" title="What is WBS?" pagename="m03_c01_p01.swf" />

<page id="03_01_02" title="Preparing a WBS" pagename="m03_c01_p02.swf" />

</chapter>


- <chapter id="03_02" title="Preparing a WBS">
<page id="03_02_03" title="Preparing a WBS" pagename="m03_c01_p03.swf" />

<page id="03_02_04" title="Preparing a WBS" pagename="m03_c01_p04.swf" />

<page id="03_02_05" title="Preparing a WBS" pagename="m03_c01_p05.swf" />

<page id="03_02_06" title="Preparing a WBS" pagename="m03_c01_p06.swf" />

</chapter>


- <chapter id="03_03" title="WBS and Earned Value">
<page id="03_03_07" title="Preparing a WBS" pagename="m03_c01_p07.swf" />

<page id="03_03_08" title="Preparing a WBS" pagename="m03_c01_p08.swf" />

<page id="03_03_09" title="Exercise" pagename="m03_c01_p09_exercise01.swf" />

<page id="03_03_10" title="Exercise" pagename="m03_c01_p09_exercise02.swf" />

<page id="03_03_11" title="Exercise" pagename="m03_c01_p09_exercise03.swf" />

<page id="03_03_12" title="Summary" pagename="m03_c01_p10_summary.swf" />

</chapter>


</module>


- <module id="04" title="Plan and Schedule the Project" foldername="content/module_04">
- <chapter id="04_01" title="Understand and Plan The Project">
<page id="04_01_01" title="Understand and Plan the Project" pagename="m04_c01_p01.swf" />

<page id="04_01_02" title="Understand and Plan the Project" pagename="m04_c01_p02.swf" />

</chapter>


- <chapter id="04_02" title="Schedule the Project">
<page id="04_02_03" title="Schedule the Project" pagename="m04_c01_p03.swf" />

<page id="04_02_04" title="Schedule the Project" pagename="m04_c01_p04.swf" />

<page id="04_02_05" title="Schedule the Project" pagename="m04_c01_p05.swf" />

<page id="04_02_06" title="Exercise" pagename="m04_c01_p06_exercise01.swf" />

<page id="04_02_07" title="Exercise" pagename="m04_c01_p06_exercise02.swf" />

<page id="04_02_08" title="Summary" pagename="m04_c01_p07_summary.swf" />

</chapter>


</module>


- <module id="05" title="Estimate and Budget Project Resources" foldername="content/module_05">
- <chapter id="05_01" title="Why Budgeting?">
<page id="05_01_01" title="Why Budgeting?" pagename="m05_c01_p01.swf" />

<page id="05_01_02" title="Why Budgeting?" pagename="m05_c01_p02.swf" />

<page id="05_01_03" title="Why Budgeting?" pagename="m05_c01_p03.swf" />

</chapter>


- <chapter id="05_02" title="Earned Value CAPs (Control Account Plans)">
<page id="05_02_04" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p04.swf" />

<page id="05_02_05" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p05.swf" />

<page id="05_02_06" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p06.swf" />

<page id="05_02_07" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p07.swf" />

<page id="05_02_08" title="Exercise" pagename="m05_c01_p08_exercise01.swf" />

<page id="05_02_09" title="Exercise" pagename="m05_c01_p08_exercise02.swf" />

<page id="05_02_10" title="Summary" pagename="m05_c01_p09_summary.swf" />

</chapter>


</module>


- <module id="06" title="EVMS Concepts and Methods" foldername="content/module_06">
- <chapter id="06_01" title="EVMS Criteria">
<page id="06_01_01" title="EVMS Criteria" pagename="m06_c01_p01.swf" />

<page id="06_01_02" title="EVMS Criteria" pagename="m06_c01_p02.swf" />

</chapter>


- <chapter id="06_02" title="EVMS Basic Terminology">
<page id="06_02_01" title="EVMS Basic Terminology" pagename="m06_c02_p01.swf" />

</chapter>


- <chapter id="06_03" title="Earned Value Methods">
<page id="06_03_02" title="Earned Value Methods" pagename="m06_c02_p02.swf" />

</chapter>


- <chapter id="06_04" title="Project Status">
<page id="06_04_03" title="Project Status" pagename="m06_c02_p03.swf" />

<page id="06_04_04" title="Exercise" pagename="m06_c02_p04_exercise01.swf" />

<page id="06_04_05" title="Exercise" pagename="m06_c02_p04_exercise02.swf" />

<page id="06_04_06" title="Summary" pagename="m06_c02_p05_summary.swf" />

</chapter>


</module>


- <module id="07" title="Monitoring Performance Against the Baseline" foldername="content/module_07">
- <chapter id="07_01" title="Performance Measurement">
<page id="07_01_01" title="" pagename="m07_c01_p01.swf" />

<page id="07_01_02" title="" pagename="m07_c01_p02.swf" />

</chapter>


- <chapter id="07_02" title="Variances and Performance Indices">
<page id="07_01_03" title="" pagename="m07_c01_p03.swf" />

<page id="07_01_04" title="" pagename="m07_c01_p04.swf" />

</chapter>


- <chapter id="07_03" title="Estimate at Completion">
<page id="07_01_05" title="" pagename="m07_c01_p05.swf" />

<page id="07_01_06" title="" pagename="m07_c01_p06.swf" />

<page id="07_01_07" title="" pagename="m07_c01_p07_exercise01.swf" />

<page id="07_01_07" title="" pagename="m07_c01_p07_exercise02.swf" />

<page id="07_01_08" title="" pagename="m07_c01_p08_summary.swf" />

</chapter>


</module>


- <module id="08" title="Integrated Baseline Review and Change Control" foldername="content/module_08">
- <chapter id="08_01" title="Integrated Baseline Review">
<page id="08_01_01" title="" pagename="m08_c01_p01.swf" />

<page id="08_01_02" title="" pagename="m08_c01_p02.swf" />

</chapter>


- <chapter id="08_02" title="Change Control">
<page id="08_01_03" title="" pagename="m08_c01_p03.swf" />

<page id="08_01_04" title="" pagename="m08_c01_p04.swf" />

<page id="08_01_05" title="" pagename="m08_c01_p05.swf" />

</chapter>


- <chapter id="08_03" title="Cost Performance Report">
<page id="08_01_06" title="" pagename="m08_c01_p06.swf" />

<page id="08_01_07" title="" pagename="m08_c01_p07.swf" />

<page id="08_01_08" title="" pagename="m08_c01_p08.swf" />

<page id="08_01_09" title="" pagename="m08_c01_p09_exercise01.swf" />

<page id="08_01_09" title="" pagename="m08_c01_p09_exercise02.swf" />

<page id="08_01_010" title="" pagename="m08_c01_p010_summary.swf" />

<page id="08_01_010" title="" pagename="m08_c01_p011_course_summary.swf" />

</chapter>


</module>


- <module id="09" title="Assessment" foldername="content/module_09">
- <chapter id="09_01" title="Assessment">
<page id="09_01_01" title="" pagename="assessment.swf" />

<page id="09_01_02" title="" pagename="Thank_you.swf" />

</chapter>


</module>

Adding Nodes And Child Nodes To An Xml Tree
Hello Ed, and every1 else.

Can i first say a big thank you for your effort, you didnt have to and i really appreciate it...im somewhat of a novice and am finding my feet.

I can now attach a comment to a node. Prior to that I have imported my xml file - which contains the tree into flash and can now display the tree structure and all of its nodes. the comment is there so thats great.

Is there any way though that you can update the xml file with the comment that you have submitted.

i.e. after you have attached the comment with a node, is there any way that the comment willl be passed through to that xml file itself?

Im thinking i need an attribute in the xml file called say "comment" and somehow when you press the submit button to attach the comment to a node the xml file (the "comment" attribute within) is also updated with the comment.

Getting A Jpg's Attributes
OK, how would I write the code to get the x and y values of a jpg's height, multiply it by a ratio (like 2/3), and then display it at a certain offset?

[XML] How To Get The Value Of The Xml Attributes
Hi

I would like to get the information of an xml file so that I can show it in a clip.

I can import my xml file and print out all of its data with trace() but I can't make a simple to print the values the attributes of each node.

Here is my very simple xml file, called doc.xml

Code:
<myroot>
<person name="foo" age="18" />
<person name="bar" age="19" />
</myroot>


My loading function for the xml file works, but not the one with my loop to get the attributes values.

Code:
// LOADING OF THE XML (works well)
var loader:URLLoader = new URLLoader();
var adress:URLRequest = new URLRequest ("doc.xml");

loader.load(adress);

loader.addEventListener(Event.COMPLETE, loadXML);

function loadXML(eventObject:Event){
var xml = new XML(eventObject.target.data);
trace(xml);

}


Code:
// XML ATTRIBUTES VALUES
// error 1120: Access of undefined property xml.
function printXML(eventObject:Event){

var myarray = xml.firstChild.childNodes;

for (var i = 0; i < myarray.length; i++)
{
var current = myarray[i];
trace(current);

}
}


What do I have to modify in my printXML function so that I can get in my loop the value of the attributes of each nodes?

many thanks for your help

merci pour votre aide

Get Attributes From XML
This is my code that loads my xml, and with some help I have been able to get at certian information in the file, but there are some attributes "w" and "d" that I need to get at and I am not quite sure how to do that. Can someone help me with this.


ActionScript Code:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
libraryList_ar = new Array();
combo_list.dataProvider = libraryList_ar;
myXML.onLoad = function(success) {
    if (success) {
        //trace(this);   
        var libraries = this.firstChild;
        var dValue = this.firstChild.attributes.name;      
        //trace(dValue);
        combo_list.textField.label.text = "Library";
        var libCount = libraries.childNodes.length;
        //trace(libCount);
        var libItems = libraries.firstChild.childNodes.length;
        //trace(libItems);   
        for (var i = 0; i<libCount; i++) {     
            libraryList_ar[i] = new Object();
            libraryList_ar[i].label = libraries.childNodes[i].attributes.Text;
            libraryList_ar[i].data = libraries.childNodes[i];         
            //save reference here
        }
    }
};
myXML.load("itemMenu.xml");

myXML looks like this

HTML Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<menu name="Library">
<menu Text="BedRoom">
<item name="Bed" ItemSWF="bed" w="65" d="84" />
<item name="Bunk bed" ItemSWF="bunkBed" w="43" d="81" />
</menu >
<menu Text="Chairs">
<item name="Recliner" ItemSWF="chair" w="40" d="35" />
</menu >
<menu Text="Sofas">
<item name="Leather Sofa" ItemSWF="sofa" w="85" d="37" />
</menu >
</menu >

How Do I Use XML Attributes
Hi I have some code I am writting for my village website.

I want to show some pictures I have the following which works but would like to know how to apply the read attributes for the XML data instead of using firstChild etc.

Here is my XML

Code:
]<?xml version="1.0" encoding="ISO-8859-1"?>

<pictureinfo>
<banner imagename = "pic1.jpg" imageurl = "http://www.mywebsite.co.uk" captiontxt = "Test 1"/>
<banner imagename = "pic2.gif" imageurl = "http://www.bbc.co.uk" captiontxt = "Test 2"/>
<banner imagename = "pic3.gif" imageurl = "http://www.mywebsite.com" captiontxt = "Test 3"/>
</pictureinfo>

<configdata>
<configitems holdtime = "10" fadeitem = "20" />
</configdata>
and here is my Action Script

Code:
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
var urls:Array = new Array();
var picname:Array = new Array();
var captions:Array = new Array();
var hold:Number = 0;
var fade:Number = 0;
//
my_xml.onLoad = function() {
var photos:Array = my_xml.firstChild.childNodes;
for (i=0; i<photos.length; i++) {
urls.push(photos[i].attributes.imageurl);
picname.push(photos[i].attributes.imagename);
captions.push(photos[i].attributes.captiontxt);
}
hold = my_xml.firstChild.nextSibling.firstChild.attributes.holdtime;
fade = my_xml.firstChild.nextSibling.firstChild.attributes.fadeitem;
};
my_xml.load("http://www.mywebsite.co.uk/picturedata.xml");
This is ok if they are in the correct order (in the XML file) I have used the "attributes" command to read in the data but dont know the correct syntax to use if I dont want to use "nextSibling.firstChild" etc.

Is there a way of reading my XML using the "pictureinfo" & "configdata" tags so that the order does not matter?

I hope that makes sense

Regards Dave

Xml Attributes.
Allright, simple questions.

i have the two following chilNode in my xml document:
Code:
<woman age="25" hairColor="Brown" name="Kay"></woman>
<woman age="22" hairColor="Pink" name="Jessica" favoriteFilm="The adventure of Jack Burton"></woman>
when my xml is loaded into flash,

1) can i know how many attributes each nodes contains ?
2) how can i list the attribute name in each node ?


What i want to do is put the name of the attributes, not there value, the name of the attributes in an array I want to have this result:
ActionScript Code:
var xWoman0:Array = new Array ("age","hairColor","name");
var xWoman1:Array = new Array ("age","hairColor","name","favoriteFilm");
if someone have an idea, please share.
thanx.



[EDIT/CyanBlue]
Please use the proper code syntax to format the code.
Read this page to find out more about the tag information
[/EDIT]

XML Attributes
Hi, I'm trying to get a grip on getting attributes from loaded XML. When I run this trace to get the attribute "runtime" from my XML file, it comes up as undefined. My XML file looks like this and is loading—I can trace the childNodes:

<?xml version="1.0" encoding="UTF-8"?>
<videoList>
<item myurl="input/FLV/lumiere2.flv" runtime="335" />
<item myurl="input/FLV/lumiere3.flv" runtime="34" />
</videoList>


=========











Attach Code

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

var Vidname:Array = new Array ();
var Vidlength:Array = new Array ();

inputXML.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
trace (this.firstChild.childNodes.attributes.runtime);
}
}

inputXML.load ("input/XML/vidlist.xml")

XML Attributes For AS
Hi,

In the following XML doc my attempt at retrieving the title attribute returns undefined, what have I missed?


[xml]
<?xml version="1.0" encoding="iso-8859-1"?>
<storyLines>
<storyLine title="lineOne">Friends, Romans</storyLine>
<storyLine title="lineTwo">, lend me your </storyLine>
<storyLine title="lineThree">; I come to </storyLine>
<storyLine title="lineFour">Ceaser, not to praise him. The evil that men do lives after them, the good is oft interred with their</storyLine>
<storyLine title="lineFive">; so let it be with</storyLine>
<storyLine title="lineSix">. The noble Brutus hath told you Ceaser was </storyLine>
<storyLine title="lineSeven">; if it were so, it was a grievous fault.</storyLine>
</storyLines>
[/xml]







ActionScript Code:
//Madlibs Version 1.4 ckimedia.com November 9. 2004//ignorewhite space, must update for AS 2.0.//November 10, 2004.XML.prototype.ignoreWhite = true;//added in version 1.4var xmlData = new XML();xmlData.onLoad = parseStoryXML;xmlData.load("story_01.xml");function parseStoryXML(success) {    //Error check - file loaded?    if (success != true) {        trace("story_01.xml failed to load");        return;    }    //Check for a malformed XML document.    if (this.status != 0) {        trace("The XML document was invalid. Error: "+this.status);        return;    }    //Make sure the first node is the storyLines node.    if (this.firstChild.nodeName.toLowerCase() != "storylines") {        trace("First node wasn't the expected <storyLines>node.");        return;    }    //Yes we do, start the parsing process    storyLinesNodeXML = this.firstChild.childNodes;    //Loop through each of the storyLine nodes    for (var i = 0; i<storyLinesNodeXML.length; i++) {        //make sure we are working with <storyLine> nodes?        if (storyLinesNodeXML[i].nodeName == "storyLine") {            //define variables            var line1;            var line2;            var line3;            var line4;            var line5;            var line6;            var line7;            //grab all the attributes from within the <storyLine>node            storyLineAttributes = storyLineNodeXML.attributes;            //Loop through all the attributes            for (z=0; z<storyLineAttributes.length; z++) {            }            trace(storyLineAttributes[z].attributeName);        }    }    /*trace(storyLinesNodeXML);        trace("The XML Document is well formed");        trace(this);*/}

XML Attributes Help
Alright, i am trying to make a copy of somthing that MLB.com has, using xml attributes and inserting them into text boxes within flash. I was wondering if someone had some kind of code that might help me actually get the information from the attributes to the text boxes... Thanx in advance for your help

Justin

XML Attributes NaN
Hey all,
I am having a weird issue with my XML

I have an xml file, the area with the issue is setup similar to :
<thumbLayout rows="1" cols="0" number="1" offset="0" thumbnailWidth="77" thumbnailHeight="39" />

I am taking these values in flash with the XPath class. The problem that I am having is that I need these variables to return as numbers so that I can build a table. They trace out fine but for some reason I can't use them as numbers. Has this happened to anyone?

Getting XML Attributes
I am trying to get certain XML attributes from my XML file into a text box. These attributes are w, d. When I click on an item in the scrollPane thumbs, I want the w and d of that item to appear in the text boxs item_h.text, and item_w.text. Now I set up a global variable for each which might not be the best way. If the Bedroom items are in the scrollPane, I can only get the last items w,d to appear regardless of what I click on.

Can someone help me figure out how to do this?


HTML Code:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<menu name="Library">
<menu Text="BedRoom">
<item name="Bed" ItemSWF="bed" w="65" d="84" />
<item name="Bunk bed" ItemSWF="bunkBed" w="43" d="81" />
</menu >
<menu Text="Chairs">
<item name="Recliner" ItemSWF="chair" w="40" d="35" />
</menu >
<menu Text="Sofas">
<item name="Leather Sofa" ItemSWF="sofa" w="85" d="37" />
</menu >
</menu >


ActionScript Code:
var myXML:XML = new XML();myXML.ignoreWhite = true;libraryList_ar = new Array();combo_list.dataProvider = libraryList_ar;myXML.onLoad = function(success) { if (success) {  //trace(this);     var libraries = this.firstChild;  var dValue = this.firstChild.attributes.name;  //trace(dValue);  combo_list.textField.label.text = "Library";  var libCount = libraries.childNodes.length;  //trace(libCount);  var libItems = libraries.firstChild.childNodes.length;  //trace(libItems);     for (var i = 0; i<libCount; i++) {   libraryList_ar[i] = new Object();   libraryList_ar[i].label = libraries.childNodes[i].attributes.Text;   libraryList_ar[i].data = libraries.childNodes[i];   //save reference here    } }};myXML.load("itemMenu.xml");//combo_list.change = function(eventObj) { thumbs.invalidate(); thumbs.refreshPane(); var selItem:Object = eventObj.target.selectedItem; var itemXML:XMLNode = selItem.data; for (var i = 0; i<itemXML.childNodes.length; i++) {  var t_mc:MovieClip;  t_mc = thumbs.content.attachMovie("thumb_mc", "thumb"+i, i, this.getNextHighestDepth());  t_mc._x = 5;  t_mc._y = 5+(i*80);  _root["mc"+i] = new MovieClipLoader();  _root["mc"+i].addListener(mclListener);  _root["mc"+i].loadClip("decals/"+itemXML.childNodes[i].attributes.ItemSWF+".swf", t_mc.Container_mc);  t_mc.i = i;  t_mc.piece = itemXML.childNodes[i].attributes.ItemSWF;  //save reference here    // get width and depth dimensions of item    _global.j = itemXML.childNodes[i].attributes.w;  _global.k = itemXML.childNodes[i].attributes.d;    // assign on release function    t_mc.onRelease = newPiece; }};combo_list.addEventListener("change", combo_list);//_global.count = 0;function newPiece() { // create a movieclip to hold the functionality of the peice of furniture // keep all the furniture inside 1 clip (called 'pieceContainer') for organizational purposes // var count:Number = floor.pieceContainer.getNextHighestDepth(); var item_mc:MovieClip = pieceContainer.createEmptyMovieClip("item_mc"+count, this.getNextHighestDepth()); //trace(count); count++; // create a container to load the furniture swf into var container:MovieClip = item_mc.createEmptyMovieClip("container_mc", 0); container._x = 0; container._y = 0; // setup a MCL to handle the swf's loading, when its loaded, apply the freeTransform methods to it.  item_mc.mcl = new MovieClipLoader(); item_mc.mcl.addListener(mclListener_2); item_mc.mcl.loadClip("decals/"+this.piece+".swf", container);  //add value of width and depth to text box   item_w.text = j; item_h.text = k;}//var mclListener_2:Object = new Object();mclListener_2.onLoadInit = function(mc:MovieClip) { // set variables to remember the original dimensions var axw = mc._width; var axh = mc._height; // trace(pieceContainer._width); trace(pieceContainer._height); // center piece   mc._y = -(axh/2); mc._x = -(axw/2); // //addFreeTransform   mc._parent.onPress = function() {  this.addFreeTransform(); };};

Using XML Attributes?
howdy,

im trying to pull attributes from my xml file for use in a dynamic text field but cant seem to get the actionscript dialed in properly...maybe YOU can help!

i have a php script which parses the data as attributes rather than nodes...so my actionscript must use these attributes!

------------------------------------------------------------------------------
my xml file is parsed as such:
------------------------------------------------------------------------------
<cars>
<car make="lambo" model="testarosa" year="2002" mileage="30k" />
<car make="ferrari" model="360" year="2003" mileage="40k" />
</cars>
------------------------------------------------------------------------------

and im trying to write a simple xml actioncript which assigns those attributes to my dynamic text fields. since its merely text, i dont need any preload script or anything fancy. i've heard that xml attributes actually load a bit faster than nodes anyway so rather than muck with my php script, im prone to make the changes in my actionscript.

------------------------------------------------------------------------------
my simple (erroneous) actionscript is as follows:
------------------------------------------------------------------------------
myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = function(success) {
if (success) {
var p = myXML.firstChild.childNodes;
make_txt.text = p[0].childNodes[0].firstChild.attributes.make;
model_txt.text = p[0].childNodes[0].firstChild.attributes.model;
year_txt.text = p[0].childNodes[0].firstChild.attributes.year;
mileage_txt.text = p[0].childNodes[0].firstChild.attributes.mileage;
}
}
myXML.load("xmltest.xml");
p = 0;
------------------------------------------------------------------------------


the dynamic text fields come up UNDEFINED every single time...any ideas or suggestions???

thanks in advance!

How To Get The Value Of The Xml Attributes
Hi

I would like to get the information of an xml file so that I can show it in a clip.

I can import my xml file and print out all of its data with trace() but I can't make a simple to print the values the attributes of each node.

Here is my very simple xml file, called doc.xml

Code:
<myroot>
<person name="foo" age="18" />
<person name="bar" age="19" />
</myroot>
My loading function for the xml file works, but not the one with my loop to get the attributes values.

Code:
// LOADING OF THE XML (works well)
var loader:URLLoader = new URLLoader();
var adress:URLRequest = new URLRequest ("doc.xml");

loader.load(adress);

loader.addEventListener(Event.COMPLETE, loadXML);

function loadXML(eventObject:Event){
var xml = new XML(eventObject.target.data);
trace(xml);

}

Code:
// XML ATTRIBUTES VALUES
// error 1120: Access of undefined property xml.
function printXML(eventObject:Event){

var myarray = xml.firstChild.childNodes;

for (var i = 0; i < myarray.length; i++)
{
var current = myarray[i];
trace(current);

}
}
What do I have to modify in my printXML function so that I can get in my loop the value of the attributes of each nodes?

many thanks for your help

XML Attributes For AS
Hi,

In the following XML doc my attempt at retrieving the title attribute returns undefined, what have I missed?


[xml]
<?xml version="1.0" encoding="iso-8859-1"?>
<storyLines>
<storyLine title="lineOne">Friends, Romans</storyLine>
<storyLine title="lineTwo">, lend me your </storyLine>
<storyLine title="lineThree">; I come to </storyLine>
<storyLine title="lineFour">Ceaser, not to praise him. The evil that men do lives after them, the good is oft interred with their</storyLine>
<storyLine title="lineFive">; so let it be with</storyLine>
<storyLine title="lineSix">. The noble Brutus hath told you Ceaser was </storyLine>
<storyLine title="lineSeven">; if it were so, it was a grievous fault.</storyLine>
</storyLines>
[/xml]







ActionScript Code:
//Madlibs Version 1.4 ckimedia.com November 9. 2004//ignorewhite space, must update for AS 2.0.//November 10, 2004.XML.prototype.ignoreWhite = true;//added in version 1.4var xmlData = new XML();xmlData.onLoad = parseStoryXML;xmlData.load("story_01.xml");function parseStoryXML(success) {    //Error check - file loaded?    if (success != true) {        trace("story_01.xml failed to load");        return;    }    //Check for a malformed XML document.    if (this.status != 0) {        trace("The XML document was invalid. Error: "+this.status);        return;    }    //Make sure the first node is the storyLines node.    if (this.firstChild.nodeName.toLowerCase() != "storylines") {        trace("First node wasn't the expected <storyLines>node.");        return;    }    //Yes we do, start the parsing process    storyLinesNodeXML = this.firstChild.childNodes;    //Loop through each of the storyLine nodes    for (var i = 0; i<storyLinesNodeXML.length; i++) {        //make sure we are working with <storyLine> nodes?        if (storyLinesNodeXML[i].nodeName == "storyLine") {            //define variables            var line1;            var line2;            var line3;            var line4;            var line5;            var line6;            var line7;            //grab all the attributes from within the <storyLine>node            storyLineAttributes = storyLineNodeXML.attributes;            //Loop through all the attributes            for (z=0; z<storyLineAttributes.length; z++) {            }            trace(storyLineAttributes[z].attributeName);        }    }    /*trace(storyLinesNodeXML);        trace("The XML Document is well formed");        trace(this);*/}

XML Attributes Help
Alright, i am trying to make a copy of somthing that MLB.com has, using xml attributes and inserting them into text boxes within flash. I was wondering if someone had some kind of code that might help me actually get the information from the attributes to the text boxes... Thanx in advance for your help

Justin

XML Attributes
xml file:
<?xmlversion="1.0"encoding="utf-8"?>

<Literals>

<gc1location="LITTLETON"page="littleton.aspx"/>

<gc2location="ARVADA"page="arvada.aspx"/>

<gc3location="GOLDEN"page="golden.aspx"/>

</Literals>


Code:
function onLoadXML() {
if (true == xmlDoc.loaded) {
trace(xmlDoc.firstChild.childNodes.length);
for (var i = 0; i<xmlDoc.firstChild.childNodes.length; i++) {
theAttributes = xmlDoc.firstChild.childNodes[i].attributes;

for ( attrib in theAttributes ) {
trace( theAttributes[attrib] );
}
}
}
}
this code gives me this:

LITTLETON
littleton.aspx
ARVADA
arvada.aspx
GOLDEN
golden.aspx


my question is:
How do I just get the 1st attribute or the 2nd attibute? Not both?

Xml Attributes.
Allright, simple questions.

i have the two following chilNode in my xml document:

<woman age="25" hairColor="Brown" name="Kay"></woman>
<woman age="22" hairColor="Pink" name="Jessica" favoriteFilm="The adventure of Jack Burton"></woman>

when my xml is loaded into flash,

1) can i know how many attributes each nodes contains ?
2) how can i list the attribute name in each node ?


What i want to do is put the name of the attributes, not there value, the name of the attributes in an array I want to have this result:


var xWoman0:Array = new Array ("age","hairColor","name");
var xWoman1:Array = new Array ("age","hairColor","name","favoriteFilm");

if someone have an idea, please share.
thanx.

XML Nodes
if I have this

Code:
<visiting-team><team-name name="TEAM NAME" alias="TN"/>
<team-city city="CITY"/>
<team-code id="5"/>
<record wins="9" losses="6" ties="0" pct=".600"/></visiting-team>


and this works for me in AS (I didn't post the whole xml file, childNode[9] is <visiting-team>)


Code:
visitingTeam[i] = xmlNode.childNodes[i].childNodes[9].firstChild.attributes["alias"];


is there no way to reference the node by name? i.e.

Code:
visitingTeam[i] = xmlNode.childNodes[i].childNodes["visiting-team"].firstChild.attributes["alias"];


I've tried the above and it does not work... but you see what I mean. Do you HAVE to reference the nodes by number and not name?

Basically.. the problem I'm having is sometimes my <visiting-team> is childNode[9] and sometimes it's childNode[12] (depending on if the game is currently being played or not). So instead of having 'basically' the same code in a few "if" loops.. I was hoping there was a way to get the value by name instead of number.

thanks

Xml Nodes
Hi Everyone, as this is my first post.
I am quite inexperienced but eager to learn actionScript, i'm a bit of an adapt-a-script cowboy really but hope to break out of that!

Can anybody helpme with the xml handler? I am trying to parse a .rss xml file using one of the tutorial scripts (i'll be honest about it), the xml that works with this script is structured somewhat differently to the standard rss
the script may look familiar, it propogates a menu from an xml list.

menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
if (success) {

//i think this section scopes down to the required level in the xml
menuItem = this.firstChild.childNodes;
for (var i = 0; i<menuItem.length; i++) {
item = _root.attachMovie("itemClip", "itemClip"+i, i);
item._x = 0;
item._y = 20*i;
item.itemLabel.text = menuItem[i].attributes.name;
item.myUrl = menuItem[i].attributes.url;
item.onRelease = function() {
getURL(this.myUrl, "_blank");
};
}
}
};
menuXml.load("myMenu.xml");


this works fine with the tutorial's supplied xml script but when i try it out with the rss i get a menu but it says undefined in all the entries.

any thoughts?

- nick (crayons)

E4X Nodes
Code:
var xml:XML =
<item>
<attribute1>WHATEVER</attribute1>
</item>

trace(xml.attribute1);//WHATEVER
trace(xml.attribute2 !== undefined);//true
trace(xml.attribute2 == undefined);//true
How can a non-existent node be undefined and not undefined at the same time?

I need to test whether a node exists so I can assign a default value if it doesn't.

thanks.

RSS A10 Nodes
Just when I thought I had this RSS reader thing beat, the RSS feeds I was using went to a different format.
Where I used to read the "description" node in AS3, they are now mostly blank and the text I am now needing is contained in this; <a10:content type="html"> some text string </a10:content>.
I used to read the description node with; [as] xml.channel.item. description [/as],
I have no idea how to parse out this a10:content node.
Any ideas?

Get Value Of All XML Nodes.
I have the following xml

Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<links>
<link name="HOME" ref="index.cfm"/>
<link name="HOW IT WORKS" ref="hiw.html"/>
<link name="BUY" ref="purchaset.html"/>
<link name="PRODUCTS" ref="pducts.html"/>
</links>
I want to pull all the "name" values and put them into one output.
Eg:HOMEHOWITWORKSBUYPRODUCTS

So it creates basically populates on textfield.

Any help?

Xml Nodes
Hi All,

I'm reasonably new to flash and xml. Basically i have a real estate xml file that our company needs to read in flash for a window display. It has different nodes <rental> / <residential> / <land> to tell flash what type of property it is. How do i tell flash to select certain nodes as i only want to display certain information depending if it is rental/land/residential.

Thanks for all your help! I am very stuck

Love,
Katherine

p.s here is the file:

<!DOCTYPE propertyList SYSTEM "http://reaxml.realestate.com.au/propertyList.dtd">

<propertyList date="20070615T141323" username="test" password="test">

<rental status="leased" modTime="20070329T092200">
<agentID>XRWBRJ</agentID>
<uniqueID>401109388</uniqueID>
<listingAgent>
<name>Kate Dennis</name>
<telephone type="mobile">0400 488 995</telephone>
</listingAgent>
<dateAvailable>20040723</dateAvailable>
<rent period="weekly" display="yes">230</rent>
<bond/>
<address display="no">
<streetNumber>85</streetNumber>
<street>Black Road</street>
<suburb>FLAGSTAFF HILL</suburb>
<state>SA</state>
<postcode>5159</postcode>
<country>AUS</country>
</address>
<municipality/>
<category name="House"/>
<headline>Great Family Home</headline>
<description>The main house comprises of 3 large bedrooms, main with built-in robes. Formal lounge, kitchen/meals with dishwasher. Ducted cooling and gas heating. Separate rumpus room with kitchenette and ensuite. Large secure yard and pets neg.</description>
<features>
<bedrooms>4</bedrooms>
<bathrooms>2</bathrooms>
<garages/>
<carports>1</carports>
</features>
<holiday value="no"/>
<landDetails>
<area unit="squareMeter"/>
</landDetails>
<buildingDetails>
<area unit="squareMeter">0</area>
<energyRating/>
</buildingDetails>
<objects>
<floorplan id="1"/>
<floorplan id="2"/>
</objects>
</rental>

<residential status="sold" modTime="20070423T160948">
<agentID>XRWBRJ</agentID>
<uniqueID>BRG10026</uniqueID>
<authority value="sale"/>
<underOffer value="no"/>
<listingAgent>
<name>Wayne Palmer</name>
<telephone type="mobile">0421 361 751</telephone>
</listingAgent>
<price display="no">500000</price>
<priceView>$450,000 - $500,000</priceView>
<address display="yes">
<streetNumber>6</streetNumber>
<street>Petrel Close</street>
<suburb>HALLETT COVE</suburb>
<state>SA</state>
<postcode>5158</postcode>
<country>AUS</country>
</address>
<municipality/>
<category name="House"/>
<headline>Family Entertainer With Views!!</headline>
<description>If there's no place like home, this is the one your won't want to miss out on. Boasting 4 spacious bedrooms (main with large ensuite, BIR's to most bedrooms), study, formal lounge & dine, large kitchen & adjacent meals, huge rumpus, double garage with auto doors, beautiful gardens, ducted heating & cooling, security system, views from Glenelg and beyond plus more!

This home must sell, don't miss out!!</description>
<features>
<bedrooms>4</bedrooms>
<bathrooms>2</bathrooms>
<ensuite>0</ensuite>
<garages>2</garages>
<carports/>
<airConditioning>0</airConditioning>
<alarmSystem>0</alarmSystem>
<vacuumSystem>0</vacuumSystem>
<intercom>0</intercom>
<pool>0</pool>
<spa>0</spa>
<tennisCourt>0</tennisCourt>
<openFirePlace>0</openFirePlace>
<otherFeatures/>
</features>
<soldDetails>
<price/>
<date>20060216</date>
</soldDetails>
<landDetails>
<area unit="squareMeter"/>
</landDetails>
<buildingDetails>
<area unit="squareMeter">0</area>
<energyRating/>
</buildingDetails>
<inspectionTimes>
<inspection>16-Oct-2005 01:00PM to 01:45PM</inspection>
</inspectionTimes>
<objects>
<img id="m" modTime="20060318T105654" url="http://www.realestate.com.au/objects/props/9536/102509536ml1142639814.jpg"/>
<img id="a" modTime="20060318T105655" url="http://www.realestate.com.au/objects/props/9536/102509536al1142639815.jpg"/>
<img id="b" modTime="20060318T105657" url="http://www.realestate.com.au/objects/props/9536/102509536bl1142639817.jpg"/>
<img id="c" modTime="20060318T105658" url="http://www.realestate.com.au/objects/props/9536/102509536cl1142639818.jpg"/>
<img id="d" modTime="20060318T105700" url="http://www.realestate.com.au/objects/props/9536/102509536dl1142639820.jpg"/>
<img id="e" modTime="20060318T105701" url="http://www.realestate.com.au/objects/props/9536/102509536el1142639821.jpg"/>
<floorplan id="1"/>
<floorplan id="2"/>
</objects>
</residential>

<land status="sold" modTime="20070420T172106">
<agentID>XRWBRJ</agentID>
<uniqueID>BRG10299</uniqueID>
<authority value="exclusive"/>
<underOffer value="no"/>
<listingAgent>
<name>Michael Burton</name>
<telephone type="mobile">0411 500 550</telephone>
</listingAgent>
<price display="yes">160000</price>
<priceView>$160,000 +</priceView>
<address display="yes">
<lotNumber/>
<streetNumber>6</streetNumber>
<street>Larkdale Avenue</street>
<suburb>MARION</suburb>
<state>SA</state>
<postcode>5043</postcode>
<country>AUS</country>
</address>
<municipality/>
<estate>
<name/>
<stage/>
</estate>
<landCategory name="Residential"/>
<headline>Excellent Courtyard Block</headline>
<description>Stake your claim as vacant land is very rare around here. A great piece of flat land in a quiet residential suburb close to Westfield Marion, Flinders Hospital, Schools and public transport. With over 400sqm theres plenty of room to build a courtyard home of your choice and have that much wanted low maintenance lifestyle.</description>
<soldDetails>
<price>180000</price>
<date>20070214</date>
</soldDetails>
<landDetails>
<area unit="squareMeter"/>
<frontage/>
<depth side="rear"/>
<depth side="left"/>
<depth side="right"/>
</landDetails>
<objects>
<img id="m" modTime="20070131T163032" url="http://www.realestate.com.au/objects/props/1826/2371826ml1170221432.jpg"/>
<floorplan id="1"/>
<floorplan id="2"/>
</objects>
</land>
</propertyList>

Xml Nodes
any suggestions how to target this node??
 <span class="title" name="title">St John's Mews, London, W11</span>

this aint doin it for me.
myText.text = textContent.firstChild.nodeName.title;

gracias

Nodes
I am getting an XML feed that I have no control over creating or changing.

Code:
<?xml version="1.0" ?>
- <root title="Goods">
- <assets>
- <row active="1" id="50">
<meta displayname="ABCs" webicon="icons/dsabc.png" /> I am trying to get these nodes
<runtime />
</row>
- <row active="1" id="51">
<meta displayname="Hat" webicon="icons/dscathat.png" />
<runtime />
</row>
- <row active="1" id="54">
<meta displayname="Pix 3" webicon="icons/szlong.png" />
<runtime />
</row>
</assets>
</root>

Code:
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function() {
var nodes = this.firstChild.childNodes.nextSibling;
numOfItems = nodes.length;
for (var i = 0; i<numOfItems; i++) {
...........
...........
xml.load("icons2.xml");
Would it be the nextSibling of firstChild.childNodes in this instance?

Can't Get # Of Nodes?
Do you think that Adobe should make better Documentation? I mean they don't even have descriptions about all the classes, parameters, and values for the XML class!Yes, it is too vague and too short and under described.3

Getting Attributes From A File
Hey there.

I need to get the height and width of a bunch of pictures in a directory.. .what is the best way to go about this? I'm making a photo album that resizes pictures depending on their ratio compared to the ratio of the available space on the stage. Here is what I'm using so far. It is far from working properly though.

_root.onEnterFrame = function() {
// when a new Photo is selected, fade out, load new image, and fade in
if (square._alpha>10 && fadeOut) {
square._alpha -= 5;
}
if (square._alpha<10) {
loadMovie("./images/image"+whichPic+".jpg", "square");
///inserted
ratio = square._width/square._height;
trace(ratio);
if (ratio<595.9/425.5) {
square._width = 595.9;
square._height = _width*ratio;
}
if (ratio>425.5/595.9) {
square._height = 425.5;
square._width = _height*(1/ratio);
}

fadeOut = false;
fadeIn = true;
}
if (square._alpha<100 && fadeIn && !fadeOut) {
square._alpha += 5;
} else {
fadeIn = false;
}
// limit input field
/*if (input>5) {
input = 5;
}*/
// initiate change to new image when Enter key is pressed
if (Key.isDown(Key.ENTER)) {
fadeOut = true;
whichpic = input;
}
};

If anyone has any suggestions I'd appreciate it. Thanks.

Scaling Attributes
I have a problem:
i made a flash site (www.grimaldimare.it) and in this project i made a movieclip called SQUARE that i used in all the site. this square is flat without stroke.
During the navigation, in the opening animation of each page, this square strech to fill the screen.
Now.
I have to make that animation only using the stroke, without fill.
I tried modifing the original movieclip, but after that, i obtain the square without fill, but the stroke scales in the transition from small to big.

HOW CAN I SET FLASH NOT TO AFFECT THE STROKE DIMENSION DURING THE SCALING ANIMATION?

please help me.
thnx.

Using XML CreateElementNode, Need To Add Attributes
Hey all-


I have a piece where I am pulling data into a menu like system from XML. The user can also add to the menu list. I am using createElementNode for this and it works well, problem is that I then need to add attributes to the new node, any ideas on how to accomplish this?

thanks
cognizen

Dynamic Attributes
Trying to write a for loop that will put all of the attributes for an xmlnode into an array for the node. How do you call the attributes if you don't know their name. I know this doesn't work but should give you an idea of what i want.


Code:
if (node.nodeName != null) {
parent[v] = new Array();
parent[v].name = node.nodeName;
for(a=0; a<node.attributes.length; a++){
parent[v][node.attributes[a].name] = node.attributes[a].value
}
}
preciate any help

Adding Txt Attributes
I have a list of variables which equal phrases. These phrases are loaded into a dynamic text box when the corresponding button is pressed.

My question is - What do I do to the txt in the variable so some words show up Bold and the rest regular in the txt box?

I tried the HTML tages but didn't get that to work is there a trick.

Thank you
gartmann

How Do I Set My RowNodeKey When I Don't Have Any Attributes In My Xml?
Ok 2004 Pro components are nice when I can get them to work. I am trying to follow along with the new components, and the new concepts for application building with AS 2.0 and the new components...

I have a application that load in xml via a XMLCOnnector and passes it to a DataSet. The DataSet is bound to a bunch of UI stuff on the stage. I can change the data in the DataSet and it is bound to a XUpdateResolver -- as per the help file. My problem is the <b>rowNodeKey</b>. All the help examples have xml files with unique attiblues inside the nodes. i.e. "id":
<b>xml</b>

PHP Code:



<xml>
<datapacket>
   <row id="1" date="01/01/2003" rate="50" hours="5" />
   <row id="2" date="02/04/2003" rate="50" hours="8" />
</datapacket>
</xml>




access by:

Code:
datapacket/row[@id='?id']
The huge xml files i am generating from Access are not layed out like that. My unique id is actaully a <b>node</b> called <b>qid</b> not an attribute.

<b>xml</b>

PHP Code:



<xml>
<dataroot>
  <xmlData>
    <qid>1</qid>
    <a>mya</a>
    <b>myb</b>
    <c>myc</c>
    <d>myd</d>
    </xmlData>
  <xmlData>
     <qid>2</qid>
     <a>mya</a>
     <b>myb</b>
     <c>myc</c>
     <d>myd</d>
  </xmlData>
</dataroot>
</xml>




I don't know what this should be - something like this?

Code:
dataroot/xmlData[@qid='?qid']
That does not seem to work. What am i doing wrong. Any ideas?

--mm

Lost Attributes
hello
i have a loop in a movie that i tried using a function for but when i use the function intead of direct code.. i lose the attirbutes being pulled in from the xml file.. i figure this is something to do with addressing but not sure how to change this..

any ideas?

below is the part of the script i mean..
code:
if (currentNode.nodeName == "blue") {
if (blue == true) {
attachMenu();
}
}

function attachMenu() {
_root[headingTarget].attachMovie("subSectionClip", "subSection"+subCount, 100+subCount);
_root[headingTarget]["subSection"+subCount].name = currentNode.attributes.name;
_root[headingTarget]["subSection"+subCount].link = currentNode.attributes.link;
_root[headingTarget].yOffset += menuSpacing;
_root[headingTarget]["subSection"+subCount]._y = _root[headingTarget].yOffset;
_root[headingTarget]["subSection"+subCount]._x = 0;
subCount++;
_root[headingTarget].subCount = subCount;
}

Setting About Xml Attributes
hi friends
i am new to xml. pls tell me the way how to create attributes for a node -<node label = "xyz" here label is an attribute .like wise if i wanna have more other than label how to do it???????/

XML Attributes To An Array
Hello,

I am having an issue with converting a XML Node attribute to an array in the movie. The attribute is a basically a list, it that looks like category=”1,0,0,0,1,0”. What I am trying to do is convert the attribute to array, and then using a for loop to reference the array index to see if it is a 1 or a 0. I am using Flash MX 2004, as always any and all help is appreciated. Below is the code I am using for the array.

code:
xmlCat = new Array();
xmlCat = _global.xmlDoc_xml.childNodes[0].attributes.category;

Accessing XML Attributes
I am having a problem with accessing the attributes of a 3rd level child node.
If anyone could help me on this, it would be great.
It's probs staring me in the face but i just can't get it working.

Here is some of the XML:

[HTML]<?xml version="1.0"?>

<projects>
<project>
<projectname>Some Project 1</projectname>
<projectclient>Some Client 1</projectclient>
<projectstatus>Some Status 1</projectstatus>
<projectinfo>lorem ipsum dolor sit amet.</projectinfo>
<projectthumb1>thumbimage1.jpg</projectthumb1>
<projectthumb2>thumbimage2.jpg</projectthumb2>
<projectthumb3>thumbimage3.jpg</projectthumb3>
<projectthumb4>thumbimage4.jpg</projectthumb4>
<projectthumb5>thumbimage5.jpg</projectthumb5>
<projectthumb6>thumbimage6.jpg</projectthumb6>
<projectthumb7>thumbimage7.jpg</projectthumb7>
<projectthumb8>thumbimage8.jpg</projectthumb8>
<projectimage1 imglabel="image one imglabel">projectimage1.jpg</projectimage1>
<projectimage2 imglabel="image two imglabel">projectimage2.jpg</projectimage2>
<projectimage3 imglabel="image three imglabel">projectimage3.jpg</projectimage3>
<projectimage4 imglabel="image four imglabel">projectimage4.jpg</projectimage4>
<projectimage5 imglabel="image five imglabel">projectimage5.jpg</projectimage5>
<projectimage6 imglabel="image six imglabel">projectimage6.jpg</projectimage6>
<projectimage7 imglabel="image seven imglabel">projectimage7.jpg</projectimage7>
<projectimage8 imglabel="image eight imglabel">projectimage8.jpg</projectimage8>
</project>
</projects>[/HTML]

Here is part of the actionscript:

x = this.firstChild.childNodes[0].childNodes[13].firstChild.nodeValue; //this is working OK.

n = this.firstChild.childNodes[0].childNodes[13].firstChild.attributes.imglabel; //this returns undefined???
trace(x);
trace(n);



thanks for any help!
ps: I have also posted this in Help/XML

How Many Attributes Can An XML Node Have?
Hi Guys

I'm reading in attributes of an XML node into my flash movie....

Is there a limit to the number of nodes you can read in?
I ask this, cause I can't read in the third attribute on my node!!

e.g. <level1 id="12" title="hello" desc="why wont this bit show up?"/>

Any ideas?

Cheers

Add Attributes To Xml Object
Code:
//create XML files

myArr = new Array("Walt_Disney_World","Fisher-Price");

// create an XML document
var doc:XML = new XML();

doc.docTypeDecl = "<?xml version="1.0" encoding="UTF-8"?>";

// create three XML nodes using createElement()
var element1:XMLNode = doc.createElement("gallery");
var element2:XMLNode = doc.createElement("album");
var element3:XMLNode = doc.createElement("element3");

// place the new nodes into the XML tree
doc.appendChild(element1);
element1.appendChild(element2);

// create two XML text nodes using createTextNode()
for(i in myArr){
var newNode:XMLNode = doc.createElement("img src=""+myArr[i]+".jpg"");
element2.appendChild(newNode);
}
this traces:

<?xml version="1.0" encoding="UTF-8"?>
<gallery><album><img src="Fisher-Price.jpg" />
<img src="Walt_Disney_World.jpg" /></album>
</gallery>

but I would like it to trace:

<?xml version="1.0" encoding="UTF-8"?>
<gallery><album title="one"><img src="Fisher-Price.jpg" />
<img src="Walt_Disney_World.jpg" /></album>
</gallery>

how do I do those attributes for the album with AS?

Filter XML Attributes
Hey,
I'm working on an site with XML driven data. I have some actionscript that returns attributes from a childnode in the xml file. This pulls attributes from many different entries, and some are duplicates. I am trying to create a filter that will return each entry only once and reject it if it already exists in the list. Any suggestions on this? Hopefully my description isnt too vague. I can attach an example if needed. Thanks!

Number Of Attributes
Hi

I have an XML file with different attributes in 1 node

for example



Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<products>

<ecoteck>
<product>
<name>lisa</name>
<image thumb="lisa_s.jpg" large="lisa_b.jpg" colors="lisa_colors.jpg" tech="lisa_tech.jpg"/>
<details inhoud="15 Kg" vermogen="1,8 - 5,5 KW" gewicht="85 Kg" verwarmingsvolume="110 m3" verbruik="0,4 - 1,25 Kg/u"/>
</product>
</ecoteck>

</products>

can we find with actionscript how many attributes are in the third node

thanx

Determining If An XML Tag Has Attributes
Does anyone know if there is a way to determine if a XML tag has attributes and if so is there a way to determine what the attribute names are without prior knowledge?

Reading Xml Attributes
I've been given a file and i need to read values from a xml file into textfields in flash.

I've looked through tutorials and the xml stuff on here but still confuzzled

I've set up the dynamic textfields etc but having problems reading in the attributres from the file...

The XML file structure is:

<dataFile>
<data id="019" att1="misc" att2="misc1">
<dataA att3="misc2" att4="misc3" />
<dataB att5="misc4" att6="misc5" />
</data>
<data id="019" att1="misc" att2="misc1">
<dataA att3="misc2" att4="misc3" />
<dataB att5="misc4" att6="misc5" />
</data>
</dataFile>

How would i read id, att1, att2, att3, att4, att5, att6 into the text fields

i've tried

for (i=0; i<total; i++) {
data[i] = xmlNode.childNodes[i].childNodes[0].attributes.id;
}

Help or links to info much appreciated.

Create Xml Attributes
Hi all,

I'm need to create and xml file with actionScript. It need to look like this:


PHP Code:



<?xml version="1.0"?>
<setProperties xmlns="testdata">
    <value>testdata1</value>
</setProperties>



I can easily set up the elements and add the 'value' text. I just don't know how to create and populate xml attributes.

Here is the coding i'm using (so far):


PHP Code:




// create an XML document
var doc:XML = new XML();    
doc.xmlDecl = "<?xml version="1.0" ?>";
    
// create three XML nodes using createElement()
var element1:XMLNode = doc.createElement("invokeOperation");
var element2:XMLNode = doc.createElement("value");
    
// place the new nodes into the XML tree
doc.appendChild(element1);
element1.appendChild(element2);
    
// create XML text nodes using createTextNode()    
var textNode1:XMLNode = doc.createTextNode("testdata1");
    
// place the new nodes into the XML tree
element2.appendChild(textNode1);
    
trace("passing xml: " + doc);




Thanks

Attributes Of A Node
Hi

Is there a way to trace all the attributes of a childnode after loading it to flash?

Thanks

Reordering XML Attributes?
I have a bunch of childs with an id="" that I would like to change after it is loaded into flash. Heres what I would like to accomplish:
ALL ids = id - 1;
ID that now = set to total number of childs.

Does that make sense? If not I can try to explain more thoroughly.

Thanks,
e39m5

How To Use CDATA For Xml Attributes..
Hi,
Is it possible to use CDATA when a special character(©, ™,®, etc) is in a node attribute??

Arrays, Attributes And E4X
Hi,

if I have xml like this:

Code:
<nodes>
<item title="aa" >bla1</item>
<item title="bb" >bla2</item>
<item title="cc" lines = "2" >bla3</item>
<item title="dd" >bla4</item>
<item title="ee" lines = "4" >bla5</item>
</nodes>
then how can I add the 'lines' attributes to an array, in which the nodes that don't contain a lines attribute (or: the non existing lines attributes) are defined as '0' ? So that you would get an array like: 0,0,2,0,4

I tried something like:

Code:
for (var h:uint=0; h< item.@title.length(); h++)
{

subMenuTitles.push (item.@title[h].toString());
if(item.@lines[h]==undefined){
var replacer:uint=0;
}
else{
replacer=item.@lines[h];
}
_corrections.push (replacer);
trace(_corrections);outputs 2,4,0,0,0

}
but it puts the lines attributes at the beginning at the array.

Thanks!

Jerryj.

Copyright © 2005-08 www.BigResource.com, All rights reserved