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








Xml With Empty Nodes HELP


I've a XML file that flash reads and then uses the values to populate text fields and load a few jpgs. The probelm is that the XML file often has NULL or empty nodes.

for example:
<item>
<name>peter</name>
<description>Some text here</description>
<image1>hous.jpg</image1>
<image2></image2>
</item>

Sometimes all the nodes have values often times they don't. The problem happens when there are multiple <item> and if there's a NULL value it throws the rest of the parsing and assigning of values into a tail spin. What can I do to avoid this? Or to make sure flash gathers the correct value?




KirupaForum > Flash > ActionScript 3.0
Posted on: 10-07-2008, 01:26 AM


View Complete Forum Thread with Replies

Sponsored Links:

Empty Xml Nodes
Dear Ultrashock,

I am trying to flow text into flash using xml, I have 3 text nodes, but all 3 of them don't always have text. Some web pages may have text for 2 of the nodes and the third node with no value displays "undefined" or "null"

Is there a way to script it so to have it display nothing when the node has no value?

Thanks!

View Replies !    View Related
Reading Empty Nodes In XML
Hi,

I have seen some threads about how to detect empty nodes in XML, but I can't make this little newsticker work. Part of the code is:

ActionScript Code:
function playThirdItem() {    var my_xml = new XML();    my_xml.ignoreWhite = true;    my_xml.onLoad = function(ok) {        if (ok) {            var field = MC.textfield;            field.html = true;            field.htmlText = this.firstChild.childNodes[2].firstChild.nodeValue;            field.setTextFormat(fmt);//THIS IS WHERE I WANT TO CHECK IF THE NODE IS EMPTY OR NOT:            if (this.firstChild.childNodes[2].firstChild.nodeValue == "") {                playFirstItem;            } else {                MC.tween("_y", 100, 1, "linear");                MC.tween("_y", 200, 1, "linear", 3);                MC.tween("_y", 0, 0, "linear", 4, playFirstItem);            }        }    };    my_xml.load("newsflash.xml");}


XML:

Code:
<news>
<item1>Jackson free man</item1>
<item2>Pope died</item2>
<item3></item3>
<item4>Berlusconi imprisoned</item4>
<item5>Bush throws party in Oval Room</item5>
<item6>New World Record 100m Swimming</item6>
</news>
Thank you for helping,

Jerryj.

View Replies !    View Related
XML - Undefined On Empty Nodes.
Hello everyone,

Im building a fiction diary for an upcoming dutch movie.
Im loading the text into a dynamic text field, the text is stored in a .XML file.
Im using a next and previous button to go to next or previous days (duh) but the buttons are also working when there isnt any information in the .XML file.
Instead of showing actual text it just shows "undefined".
Is there any way to tell the buttons to not go to the next node if its not there?
I attached the .fla so you can check out the code.

I've been looking for a fix for ages now and this is my last resort.
Thanks in advance

//EDIT//

This is the actual code im using to load in the XML data:

Code:

function leesXML(geladen) {
if (geladen) {
_root.content2.tekstVeldje01.htmlText = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
_root.content2.tekstVeldje02.htmlText = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
trace (_root.content2.tekstVeldje01.htmlText);
}
}

onzeGegevens = new XML();
onzeGegevens.ignoreWhite = true;
onzeGegevens.onLoad = leesXML;
onzeGegevens.load("XML/dagboek.xml");
Now im just looking for a way to make flash go to the next node and read out that info when someone presses the go to next entry button.

Nick

View Replies !    View Related
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.

View Replies !    View Related
Grabbing The Empty Space Of An Empty Movie Clip
OK, so I've created an emptymovie clip and have attached clips to it, so that when I attach a drag action (actually, I did the drag through onPress and onRelease), the user can click and drag all the clips at once. However, it only detects when I click on one of the actual child clips...I'd like to be able to click on the space between the clips.

Here's the swf:
http://www.public.iastate.edu/~dnguy.../scrapbook.swf


The relevant code:

Code:
this.createEmptyMovieClip("mainclip", 1);

for(var i=0; i < nPics; i++){
var cclip = mainclip.createEmptyMovieClip("clip_"+fileNames[i], i);


myMCL.loadClip( gFolder + "/" +
fileNames[i],
cclip);

}

Code:
mainclip.onPress = function(){
this.xoff = this._xmouse;
this.yoff = this._ymouse;
this.onMouseMove = DragClip;

}

mainclip.onRelease = function(){
mainclip.onMouseMove = null;

}

function DragClip(){

this._x = _root._xmouse - this.xoff;
this._y = _root._ymouse - this.yoff;

}

View Replies !    View Related
Very Weird... Empty/non-empty Button Problem/bug
hey... i was just messing around when i had this code

ActionScript Code:
txt.autoSize = "left";btn.onRelease = function(){trace("it doesnt work!");}btn._width = txt._width;txt2.autoSize = "left";btn2.onRelease = function(){trace("it works!");}btn2._width = txt._width;


as you have read, the one does work and the other doesnt... that's quite weird because there almost the same buttons (not movieclips, buttons)... EXCEPT for this: the one that doesnt work is empty (only the hit tab is filled with a shape) and the other one has the up and hit area filled... i attached i fla to make it more clear

who has a good explanation for this problem(/bug)

View Replies !    View Related
How To Check Is An Empty MovieClip Is Really Empty?
I'm creating an empty movieClip that will load a new .swf (from a _global variable) if the empty movieClip is really empty. Unfortunately, I'm not really sure how to check to see if it's empty. Any suggestions would be appreciated.

My code currently looks like this:

// Initialize variables
_global.sceneVar = "CiA_Master2.swf";
// creat empty movie clip
var container:MovieClip = createEmptyMovieClip("container", 2);
var mcLoader:MovieClipLoader = new MovieClipLoader();
//"IF" statement would go on this line, perhaps something like this (?): if(container = "") {
mcLoader.loadClip(sceneVar, container);
//end "IF" statement

I'm hoping to use this in a master .swf that will load other modular .swf files into it.

View Replies !    View Related
How Do I Empty An Empty Movie Clip
hello

how do I remove a movie clip off of the stage that I created using

createEmptyMovieClip

Thanks in advance

View Replies !    View Related
Empty Frame Not Really Empty?
Hey,
Ok, this may be confusing but I'll do my best to explain it. I have a movie clip, we'll call it frustratingMC, with some code on it. This code draws something onto the stage (the parent of the movie clip) based on the movie clip's position. it's built this way because you are supposed to just be able to drag the movie clip onto the stage and be done with it. The thing is, if I put frustratingMC onto a keyframe on the stage, and a later keyframe does not have frustratingMC on it, I still get frustratingMC in the list when I run this code to see what's on the stage:

Code:
for(var a in _root) {
trace(a);
}
I've tried the same thing with a regular movie clip with no drawing code on it and that movie clip gets removed from the list like I would think it should. I could understand maybe if the drawn stuff didn't go away, but shouldn't frustratingMC go away? Thanks.
--dan

View Replies !    View Related
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

View Replies !    View Related
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)

View Replies !    View Related
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.

View Replies !    View Related
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?

View Replies !    View Related
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?

View Replies !    View Related
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>

View Replies !    View Related
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

View Replies !    View Related
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?

View Replies !    View Related
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

View Replies !    View Related
Writing New XML Nodes
I know that you can remove XML nodes in Flash, but does anyone know if you can concatenate new nodes to an external XML file in Flash MX?

View Replies !    View Related
Adding Nodes
Hi! i don´t know how to add nodes to a previously designed draw! Can you help me? Thanks!

View Replies !    View Related
Accessing Xml Nodes
Hi

I have a file like:
code:
<xml>

<item1>
<item1.1 test="text1">
</item1>

<item2>
<item2.1 test="text2">
</item2>

<item3>
<item3.1 test="text3">
</item3>

</xml>

I can access text 1 like this:

this.firstChild.firstChild.childNodes;

text 2 like:

this.firstChild.firstChild.nextSibling.childNodes;

but how do I acces text 3?

this.firstChild.firstChild. nextSibling. nextSibling.childNodes;

would be the obvious choice but doesn't work.

thanks

View Replies !    View Related
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

View Replies !    View Related
Count All Nodes In Xml?
I would like to count all the nodes in xml....If I have a XML like this.,...

<category name="a">
<item id="1">
<item id="2">
<item id="3">
</category>
<category name="b">
<item id="4">
<item id="5">
<item id="6">
</category>

I should get 8...or if its not possible...Is there a way I can able to count all the nodes which has the name="item" ...is it possible?

Thanks



function loadXML(_file)
{
var navigation_xml = new XML();
navigation_xml.ignoreWhite = true;
navigation_xml.onLoad = function(success)
{
if (success)
{
CreateMenu(this);
trace("loading xml" ;
}
else
{
trace("Error loading XML file" ;
}
}
navigation_xml.load(_file);
}

function CreateMenu(xmllist){
trace("starting to create the mennu" ;
items = xmllist.firstChild.childNodes;
var item_count=0;
var item_spacing = 40;

for (i=0;i<items.length;i++)
{
//parse the attributes and assign the values

}
}

View Replies !    View Related
Is It Possible To Write To XML Nodes?
Is It Possible to write to XML nodes and then export the entire xml contents to a php file so it can be written as a new modified xml file?

Thanks.

View Replies !    View Related
Replacing Nodes In Xml (AS 3.0)
I have a xml file


PHP Code:




<idioma>
  <ingles>
     <cat1>value1</cat1>
     <cat2>value2</cat2>
  </ingles>
  <espanol>
      <cat1>value3</cat1>
      <cat2>value4</cat2>
  </espanol>
</idioma>







how can I replace the value of cat1 with the function replace() ?

View Replies !    View Related
Attaching Nodes
ok this might be a stupid question, i would love some help though.. here is the problem i have this for loop

for (var i = 0; i<30; i++) {
var node:MovieClip = attach.attachMovie("node", i, i++);
node._y = (10*i)+10;
}

it places 30 copys of node on the screen, but i need each node to be clickable and a different responce for each. eg first node would trace a, second node would trace b! can this be done? i assume it can but i can not get my head round it!! i have tried this...

for (var i = 0; i<30; i++) {
var node:MovieClip = attach.attachMovie("node", i, i++);
node._y = (10*i)+10;
node.onRelease = function() {
trace("fsdfs");


};
}

but then every instance of node traces ("fsdfs"); can any one sugest anything?

cheers this would be much apreciated

sam

View Replies !    View Related
Insert Nodes XML
Hi!

We are parsing a XML file and in some point we need to put another nodes inside some kind of special nodes. These new nodes must NOT be serialized to the XML file in the FileSystem.

When we need a sibling sometimes we need to put a new node before it, sometimes after it.

how could we do that?

below a example of what we are trying to do:

function parseXML(pNode:XMLNode):Void {
if (pNode.childNodes.length < 1) return;

for (var i = 0; i < pNode.childNodes.length; i++){
if (_before != undefined) {
//We need to put this new node BEFORE the _current node.
pNode.appendChild(new XML("<p><font size='" + marginBottom + "'>&nbsp;</font></p>"));
}

if (_after != undefined) {
//We need to put this new NODE after the _current node.
pNode.appendChild(new XML("<x><font size='" + marginBottom + "'>&nbsp;</font></x>"));
}
parseXML(pNode.childNodes[i]);
}
}

Cheers

View Replies !    View Related
Navigating XML Nodes
I'm losing the will to live here...
I have read Jesse Stratford's tut XML 101 but the firstChild/nextSibling/childNodes/nodeValue stuff isn't sinking in.

I can't work out how to go about collating all the data in the xml structure below and then add it to an object in Flash then move each node’s value into the object, using the node name as the object's attribute name(as in the tut). So I could do trace(example.tom.image) and I'd get back "images/tom.jpg".

Whatever I do I either get null, undefined or I get the entire xml duplicated three times? Can anyone help me out here?


PHP Code:



<example>
  <tom>
    <name>Tom</name>
    <age>40</age>
    <image>images/tom.jpg</image>
  </tom>
  <dick>
    <name>Dick</name>
    <age>25</age>
    <image>images/dick.jpg</image>
  </dick>
  <harry>
    <name>Harry</name>
    <age>17</age>
    <image>images/harry.jpg</image>
  </harry>
</example> 

View Replies !    View Related
Total Nodes Of XML
I have problems to figure out how I should count the total nodes of my XML, so the loading of XML-data will begin from the beginning when it reaches the end (the first five nodes in the XML are not used):

PHP Code:



//första textfältet för rubriken skapas

createTextField("rubrik", this.getNextHighestDepth(), 10, 10, 900, 30);
rubrik.html = true;
rubrik.htmlText = "<a href='localhost'>Laddas...</a>";
var stilRubrik:TextFormat = new TextFormat();
stilRubrik.bold = true;
stilRubrik.size = 18;
stilRubrik.font = "Georgia";
rubrik.html = true;
rubrik.setTextFormat(stilRubrik);
rubrik.selectable = false;



// Brödtexten
// ordningen på create feield props - värde: namnet, nivå, vänsterindrag, topp, längd, höjd på textfältet

createTextField("brodtext", this.getNextHighestDepth(), 10, 40, 300, 200);
brodtext.multiline = true;
brodtext.wordWrap  = true;
brodtext.text = "Här är brödtexten. Här är brödtexten. Här är brödtexten. Här är brödtexten. Här är brödtexten. Här är brödtexten.";
var stilBrodtext:TextFormat = new TextFormat();
stilBrodtext.bold = false;
stilBrodtext.size = 11;
stilBrodtext.font = "Georgia";
brodtext.setTextFormat(stilBrodtext);

createEmptyMovieClip("bilden", this.getNextHighestDepth());
bilden._x = 390;
bilden._y = 40;
bilden.loadMovie("http://kliv.basetool.se/upload/53202_List_Img_ListImg_20070125130013.jpg");

// och så var det dags för lite XML hokus pokus

headlineXML = new XML();

    
var my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success){
if (success){
korfil()
}
}
System.security.allowDomain("http://kliv.basetool.se/");
System.security.allowDomain("http://extepiutv.vgregion.se/");
my_xml.load("http://extepiutv.vgregion.se/upload/xml/Kalenderbildspel/2036.xml");


i = 5;

function korfil()
{
    
    
grunden = my_xml.firstChild.firstChild;
id = grunden.childNodes[i].childNodes[0];
bild = grunden.childNodes[i].childNodes[1].childNodes[0];
titel = grunden.childNodes[i].childNodes[2].childNodes[0];
body = grunden.childNodes[i].childNodes[3].childNodes[0];
lank = grunden.childNodes[i].childNodes[6].childNodes[0];
rubrik.htmlText = '<a href ="' + lank + '">' + titel + '</a>';
bilden.loadMovie(bild);
brodtext.htmlText = body;
brodtext.setTextFormat(stilBrodtext);
rubrik.setTextFormat(stilRubrik);
i++;

}

run = setInterval(korfil, 5000, this) 




The XML-file is here:
http://extepiutv.vgregion.se/upload/...dspel/2036.xml

View Replies !    View Related
XML Nodes And Parsing
Hi all,

Just wondering if anyone can tell me how to retain "carraige returns" from text that I am loading in from an external xml file.
I was under the impression that CDATA tags would catch things like returns, but it seems that they get interpreted as TWO (2) carraige returns, leaving an extra space where I simply wanted the "next line".

example:

<![CDATA[things that i don't want to do.
things that i would love to do.]]>

gets changed to:

things that i don't want to do.

things that i would love to do.

when i was hoping for:

things that i don't want to do.
things that i would love to do.

any suggestions?
thanks,
f_y

View Replies !    View Related
XML Nodes Help Required
I am completley new to Actionscript so please excuse my ignorance. I am trying to pull data in from an ASP page which outputs XML.

When I perform a trace in flash on the loaded page, eg. trace(ob.firstChild.nextSibling) It returns <MONEY>2000000</MONEY>

but when I trace(ob.firstChild.nextSibling.nodeValue) it returns null. Should this not return 2000000? This worked on another tag <NAME>, is this something to do with the result being numbers?

Any ideas?

View Replies !    View Related
Xml Nodes - Frustrating
I am re-posting this here because it is actually an action script question (not Flash 8 General)

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.


ActionScript Code:
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)

View Replies !    View Related
Targeting Xml Nodes In AS3
hey there
I have just managed to draw xome dynamic xml into flex.
Now what I want to do is target the data in the xml.
I have tried things like pointing to the node name etc but to no avail.


This is my xml:

Code:
<results xmlns:xsi="http://www.w3.org/2001/XMLSchema-inst
ance">
<sizeOfMarket>
<data>
<date>Current MAT</date>
<current>6751307</current>
<target>607618</target>
<benchmark>664977</benchmark>
<market>715639</market>
</data>
<data>
<date>Previous MAT</date>
<current>7074226</current>
<target>664977</target>
<benchmark>664977</benchmark>
<market>764016</market>
</data>
</sizeOfMarket>
<volume>
<data>
<date>DJ 2005</date>
<current>672589</current>
<target>609685</target>
<benchmark>798238</benchmark>
</data>
<data>
<date>JJ 2005</date>
<current>699592</current>
<target>636500</target>
<benchmark>779754</benchmark>
</data>
</volume>

This is the class that I have used.


Code:
package classes
{
import flash.display.Sprite;
import flash.xml.*
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.events.*;
import mx.collections.XMLListCollection;
import flash.xml.*

public class xml_data_loader /*extends XMLListCollection*/
{


public static function call_XML(bool:Boolean) :void{
if(bool){

trace("LOADING DYNAMIC XML DATA");
var myXML:XML = new XML();
var XML_URL:String = "../assets/data.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener( Event.COMPLETE, xmlLoader );
myLoader.load( myXMLURL );
function xmlLoader(evtObj:Event) :void
{
myXML = XML(myLoader.data);
trace("DATA LOADED");
xml_Parser(myXML);
//trace(myXML);

}

function xml_Parser(myXML:XML){
var DATA:XML = myXML;
var _slide:String = DATA.results.sizeOfMarket;
trace("PARSER DATA NODE TRACE:"+_slide);
}



}
}


}


}
Does anybody have a quick solution for this problem??

Any Help would be much appriciated..

cheers

View Replies !    View Related
Deleting XML Nodes
Hi all,

I am trying to delete an xml element but I keep getting this error:

Code:
TypeError: Error #1119: Delete operator is not supported with operand of type XMLList.
Here is the code I am using

Code:
delete ListsData.list.(@type == "favor").item.(@sn==ent);
any idea how this might work?
cheers

View Replies !    View Related
Sorting Nodes In Xml
I'm wondering if nodes in an xml file can be sorted according to different attrtibute values. like date, alphabetical order or titles, etc... rearranged then read by flash?

Can flash's xml object do this? PHP maybe?

View Replies !    View Related
Shuffle XML Nodes
During the onLoad of an XML file, I would like Flash to do a random shuffle of the XML nodes.

Each node contains a song title and mp3 URL. Need to shuffle the order of the nodes.

Any ideas on how to code that?

Thanks.
-CK







Attach Code

// Load the songs XML
var xmlgenre:XML = new XML();
xmlgenre.ignoreWhite = true;
xmlgenre.onLoad = function()
{
var nodes:Array = this.firstChild.childNodes;
for(var i=0;i<nodes.length;i++)
{
sa.push(new Song(nodes[i].attributes.url, nodes[i].attributes.artist, nodes[i].attributes.track));
}
playSong();
}

xmlgenre.load(xmlFile);

View Replies !    View Related
Swapping Nodes
Does anyone have a decent way of swapping the positions of xml nodes?
ex:
<top><thing1>ONE</thing1><thing2>TWO</thing2></top>

Now swap the positions of ONE and TWO to make it look like this:
<top><thing2>TWO</thing2><thing1>ONE</thing1></top>

I have been trying cloning and insertBefore.. but getting nowhere. AS3 !

View Replies !    View Related
XML: Sorting XML Nodes
How would I sort a bunch of XML nodes? I don't necessarily need to change the existing structure, but I do need to iterate through in a specific order. In AS2 I would use the childNodes array and use Array.sort.

View Replies !    View Related
Random XML Nodes
I am trying to create a random quote generator in Flash MX. I have built an XML file with a bunch of quotes, and currently, when the user clicks the "next" button, the application goes to the very next quote in the XML file. This is not "random" as I'd like it to be, and was wondering if anyone has any experience in randomizing data that is found in an XML file. Below is my actionscript:

quotes_xml = new XML();
quotes_xml.onLoad = startQuoteShow;
quotes_xml.load("quotes.xml");
quotes_xml.ignoreWhite = true;
//
// Show the first quote and intialize variables
function startQuoteShow(success) {
if (success == true) {
rootNode = quotes_xml.firstChild;
totalQuotes = rootNode.childNodes.length;
firstQuoteNode = rootNode.firstChild;
currentQuoteNode = firstQuoteNode;
currentIndex = 1;
updateQuote(firstQuoteNode);

}
}
//
// Updates the current slide with new image and text
function updateQuote(newQuoteNode) {
id = newQuoteNode.attributes.id;
author = newQuoteNode.attributes.author;
quoteText = newQuoteNode.firstChild.nodeValue;
//loadMovie(imagePath, targetClip);
}
//
// Event handler for 'Next quote' button
next_btn.onRelease = function() {
//nextQuoteNode = currentQuoteNode.nextSibling;
nextQuoteNode = random(currentQuoteNode.nextSibling);
trace (nextQuoteNode);
if (nextQuoteNode == null) {
break;
} else {
currentIndex++;
updateQuote(nextQuoteNode);
currentQuoteNode = nextQuoteNode;
}
};

View Replies !    View Related
Help With XML, Looping Through Nodes
I'm creating a navigation that is populated by an XML file. It loops through the amount of "client" nodes in the XML file and attaches a movie clip to the stage for each instance of the "client" node. I have the list populating fine as well as some buttons to make the list scroll. I'm unsure how to attach button states/actions to each of the created clips though.

Each "client" node has multiple "image" child nodes. In my current XML file each "client" has 3 "image" child nodes, though in my final XML file the number could vary from 1 - 10. My question is this. How can I attach roll over and release states to each of the attached clips? I am trying to trace the amount of "image" child nodes each client has when one of the clips is released.

I've attached my source file (MX04) for anyone to view. I know this isn't the easiest question and I greatly appreciate any help with it.

View Replies !    View Related
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 ala
http://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

View Replies !    View Related
Counting Nodes From XML
Hi,

Let's say I have a XML file with three types of nodes; type1, type2 and type3.
How do I count the number of nodes named type1?


Thanks

View Replies !    View Related
XML Nodes--next Sibling
Hello everyone. This is my first time using this forum. What an excellent site. I've learned a lot about using xml with flash through this site. I have expanded upon the example to build an xml menu using flash.

The file I have created loads videos dynamically

Loads Sounds Dynamically

Includes a title Class to display titles

Includes a RollOver class to display on rollover events when you mouse over the titles.

It is a very useful little application.

But I would like to build arrows so that you can navigate among each of the individual sub menus using a forward, and back arrow button.

I have tried to do this with no success, if anyone can help me, I'm attaching the fla...

Everyone feel free to use it, as it has been a great learning tool for me, and will lessen some of my heavy work load, since it's basically a multimedia shell with all the addtions.

Thanks kirupa.com & it's creator.

View Replies !    View Related
Nodes In XML Feeds - [F8]
Hiya there!

I have been following this tutorial quite closely, however I still can't display the <item> section of an xml RSS feed in the flash.

Here's a snippet of the feed


Code:
<rss version="2.0">
<channel>
<title>Blah</title>
<link>www.something.com</link>
<description>Description</description>
<item>
<title>NEWS</title>
<link>link</link>
<description>The most exciting news on the universe! :P</description>
</item>
</channel>
</rss>
How can I display the title and the description?
(I'm having trouble with the nodes part...)

Any help is greatly appreciated!

Thanks!

View Replies !    View Related
XML Nodes With The Same Name And Flash
I have a simple search form on my site. It allows users to pull data from a database and then display that data. So the user would select the data set they want, a PHP script queries the database, and then puts that data into a XML file. This part is working fine.

However I can not seem to get the data to display correctly in Flash. I tried the tutorial on this site for Flash and XML, and it works, but only displays one result. The problem I believe is that all the child nodes have the same tag. My XML file would look something like:


Code:
<?xml version="1.0" ?>
<Users>
<Name>John Doe</Name>
<Name>Dave Doe</Name>
<Name>Jane Doe</Name>
</Users>
I am new to AS, and can't find anything to show how to display multiple results all the with same tag name. The flash file only shows the first result. Can anyone show me a tutorial or a guide on how to display all the items from the XML file in a dynamic text box?

My current AS code is:


Code:
list_xml = new XML();
list_xml.ignoreWhite = true;
list_xml.onLoad = loadXML;
list_xml.load("file.xml");
function loadXML(loaded) {
if (loaded) {
_root.users = this.firstChild.childNodes[0].firstChild.nodeValue;
_root.name = this.firstChild.childNodes[0].firstChild.nodeValue;
name_txt.text = _root.name;
}
else {
trace("file not loaded!");
}
}

View Replies !    View Related
Looping Through XML Nodes
I'm having trouble looping through the "subitem" node in the following XML doc. The "item" node is being used for 1st level menu links and the "subitem" nodes ("name" attribute) would be used for the 2nd level links. Can anyone help me here?


Code:
<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
<menu>
<item name="Modernism" type="menuCategory">
<subitem name="Roots" filename="roots.swf"/>
<subitem name="Arrival" filename="arrival.swf"/>
<subitem name="Post-War Optimism" filename="postwar.swf"/>
<subitem name="Doubts" filename="doubts.swf"/>
<subitem name="The Bubble Bursts" filename="bubble.swf"/>
<subitem name="Post-Modernism" filename="postmodern.swf"/>
<subitem name="Revival" filename="revival.swf"/>
</item>
<item name="Architects" type="menuCategory">
<subitem name="Frank Lloyd Wright" filename="wright.swf"/>
<subitem name="Walter Gropius" filename="gropius.swf"/>
<subitem name="Ludwig Mies van der Rohe" filename="mies.swf"/>
<subitem name="Le Corbusier" filename="lecorbusier.swf"/>
</item>
<item name="Buildings" type="menuCategory">
<subitem name="Fallingwater" filename="fallingwater.swf"/>
<subitem name="Bauhaus" filename="bauhaus.swf"/>
<subitem name="German Pavilion" filename="gpavilion.swf"/>
<subitem name="United Nations" filename="un.swf"/>
</item>
<item name="Contacts" type="menuCategory">
<subitem name="Contact Us" filename="contacts.swf"/>
</item>
</menu>

View Replies !    View Related
Need Some Help With Xml Nodes In Flash
hi, i worked on this code earlier today and had saved it as version 8, but when i got home i couldn't open it. so...i tried to recreate it from memory, which is always a bad idea for a sleep-deprived mommy.

here's my actionscript code:

var blocks:Array = new Array(txt0,txt1,txt2);
var stories:Array = new Array();

var headlineXML:XML = new XML();
headlineXML.ignoreWhite = true;
headlineXML.onLoad = function(success){

if (success){
parse();
trace(this);
}
}

headlineXML.load("headlines2.xml");

function parse() {
var broadcastXML = headlineXML.firstChild;
var storyNode = broadcastXML.childNodes;

for (var i=0; i<storyNode.childNodes.length; i++){

currStories = stories[i];
currLead = storyNode.firstChild.childNodes[0];
currBody = storyNode.firstChild.childNodes[1];
currURL = storyNode.firstChild.childNodes[2];
currtxt = blocks[i];

currtxt.htmlText = currLead.firstChild.childNodes.nodeValue[0]+"<br>"+currBody.firstChild.childNodes.nodeValu e[0]+"<br>"+currURL.firstChild.childNodes.nodeValue[0];
}
}

and here's my xml doc structure:

<broadcast>
<story>
<lead>This is Headline 1</lead>
<body>This is where you can add content that will appear under the first headline</body>
<URL><a href="http://www.nytimes.com">www.nytimes.com</a></URL>
</story>
<story>
<lead>This is Headline 2</lead>
<body>This is where you can add content that will appear under the second headline</body>
<URL>http://evanchik.net</URL>
</story>
<story>
<lead>This is Headline 3</lead>
<body>This is where you can add content that will appear under the third headline</body>
<URL>http://www.kirupa.com</URL>
</story>
</broadcast>

any help would be appreciated...i'm getting nowhere and i need to get this well underway by the end of the weekend. i also need to load images and style the text, but for now i just want it to loop thru the text arrays properly. *sigh* and to show my text!

thanks!

View Replies !    View Related
Need Some Help With Calling Xml Nodes
hi, i worked on this code friday and had saved it as version 8, but when i got home i couldn't open it. so...i tried to recreate it from memory, which is always a bad idea for a sleep-deprived mommy ;-)

here's my actionscript code:

var blocks:Array = new Array(txt0,txt1,txt2);
var stories:Array = new Array();

var headlineXML:XML = new XML();
headlineXML.ignoreWhite = true;
headlineXML.onLoad = function(success){

if (success){
parse();
trace(this);
}
}

headlineXML.load("headlines2.xml");

function parse() {
var broadcastXML = headlineXML.firstChild;
var storyNode = broadcastXML.childNodes;

for (var i=0; i<storyNode.childNodes.length; i++){

currStories = stories[i];
currLead = storyNode.firstChild.childNodes[0];
currBody = storyNode.firstChild.childNodes[1];
currURL = storyNode.firstChild.childNodes[2];
currtxt = blocks[i];

currtxt.htmlText = currLead.firstChild.childNodes.nodeValue[0]+"<br>"+currBody.firstChild.childNodes.nodeValu e[0]+"<br>"+currURL.firstChild.childNodes.nodeValue[0];
}
}

and here's my xml doc structure:

<broadcast>
<story>
<lead>This is Headline 1</lead>
<body>This is where you can add content that will appear under the first headline</body>
<URL><a href="http://www.nytimes.com">www.nytimes.com</a></URL>
</story>
<story>
<lead>This is Headline 2</lead>
<body>This is where you can add content that will appear under the second headline</body>
<URL>http://evanchik.net</URL>
</story>
<story>
<lead>This is Headline 3</lead>
<body>This is where you can add content that will appear under the third headline</body>
<URL>http://www.kirupa.com</URL>
</story>
</broadcast>

any help would be appreciated...i'm getting nowhere and i need to get this well underway by the end of the weekend. i also need to load images and style the text, but for now i just want it to loop thru the text arrays properly. *sigh* and to show my text!

thanks!

View Replies !    View Related
TICKER HELP, XML Nodes
Hi All,
I've been working with the Ticker code, http://www.kirupa.com/developer/mx2004/newsticker.htm I think I am bald now from pulling my hair out. ; )

I added a new dynamic text box in flash and line of code in my xml file (subject) that I want to only enter once in my xml file, and I got it working, however, my first child in the list pulls as undefined. Then it will read it. I'm not sure what I am missing. I'm sure it's an easy fix for someone who knows what they are doing.
Anyone???

I attached my files.

thanks

View Replies !    View Related
Counting XML Nodes
Hello, I've got a few issues with something Im working with here, but I'll just do one at a time.
I am attempting to create a Flash Banner for my bands website and I am trying to include some information about future gig's that my band may be performing along the bottom, just Date and Location as of now, the way I am currently doing this is by having each child node of root node in the XML file numbered:


Code:
function loadXML(loaded) {
if (loaded) {
if (n >= 1) {
_root.GigTxt.dtMov.dtTxt.text = _root.date;
_root.GigTxt.lcMov.lcTxt.text = _root.location;
_root.date = this.firstChild.childNodes[n].childNodes[0].firstChild.nodeValue;
_root.location = this.firstChild.childNodes[n].childNodes[1].firstChild.nodeValue;
Let me clear this up a bit, I start my timeline with the following action, "n = 0". and then want some script to count how many nodes the Root node in my XML file has as children, which I then want to return as a value which I can call "nTot" (Shortened from Node Total).

I also have codes in my .fla file which determine which node should be displayed at which time. For instance:


Code:
if (nTot <= 0) {
n = 0;
} else if (n < nTot && nTot >= 1) {
n = n + 1;
}
if (n > nTot) {
n = 1;
}
Please bare in mind at this time that I want The First Child of the root node in my XML file to display "No Gigs Planned" thats why if nTot is 0 nothing but the First Child of the Root Node will be shown. I hope this all makes sense. Please help.

Right now I would just like some assistance in creating a code that will count nodes in an XML file and then return a value to be known as "nTot" (can someone tell me the technical term for this method, replacing a value with a word/letter?)

Thanks in advance for your help!

P.S: Whenever I view the swf file, There always seems to be some form of margin formed,.. why!?

View Replies !    View Related
Searching Within Xml Nodes
How do you search through entire xml nodes? I'm only finding information on how to search for an exact string, and inside one attribute.

Here's my xml code:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<projects>
<project id="1" name="Empire State Building" location="New York">
<description>The Empire State Building is a 102-story art deco skyscraper in New York City, New York at the intersection of Fifth Avenue and West 34th Street. Its name is derived from the nickname for the state of New York. It stood as the world's tallest building for more than forty years, from its completion in 1931 until construction of the World Trade Center's North Tower was completed in 1972. Following the destruction of the World Trade Center in 2001, the Empire State Building became for the second time the tallest building in New York City.</description>
<images>
<image file="esb/esb1.jpg" name="Close Up" />
</images>
</project>
<project id="2" name="500 Fifth Avenue" location="Manhattan">
<description>500 Fifth Avenue is a 60-storey, 697-foot (212 m) office tower in Manhattan, New York City, standing at West 42nd Street.[1] It is adjacent to Bryant Park.</description>
<images>
<image file="ffa/ffa1.jpg" name="Close Up" />
</images>
</project>
</projects>
Is there a simple function to have it return the IDs of the "projects" that contain the search term?
Say I do a search for "New York", both projects show up, but if type in "Bryant", the second one shows up? I can't find anything about this in the xml chapter in essential actionscript...

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved