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




Parsing XML - Almost There



Ok, here is my question; I want to parse the below xml document and assign
the correct answer text to a variable for example the following node has a value of 8

<answer correct = 'y'>8</answer>


How do I identify that in my parsing function



Code:

<?xml version="1.0"?>
<quiz>
<title>Addition</title>
<items>
<item><question>What is 2 + 2=</question><theimage>Http://www.myURL.com</theimage><answer>6</answer><answer correct = 'y'>4</answer><answer>5</answer><answer>8</answer></item>
<item><question>What is 3 + 8=</question><theimage>Http://www.myURL.com</theimage><answer correct = 'y'>11</answer><answer>10</answer><answer>8</answer><answer>9</answer></item>
<item><question>What is 9 + 1 =</question><theimage>Http://www.myURL.com</theimage><answer>9</answer><answer correct = 'y'>10</answer><answer>7</answer><answer>8</answer></item>
<item><question>What is 4 + 4 =</question><theimage>Http://www.myURL.com</theimage><answer>5</answer><answer>6</answer><answer>7</answer><answer correct = 'y'>8</answer></item>
</items>
</quiz>


Code:

function onQuizData(success)
{
var quizNode=this.firstChild;
var quizTitleNode=quizNode.firstChild;
title=quizTitleNode.firstChild.nodeValue;

var i=0;
// <items> follows <title>
var itemsNode=quizNode.childNodes[1];
while (itemsNode.childNodes[i])
{
var itemNode=itemsNode.childNodes[i];
// <item> consists of <question> and one or more <answer>
// <question> always comes before <answer>s (node 0 of <item>)
var questionNode=itemNode.childNodes[0];
quizItems[i]=new QuizItem(questionNode.firstChild.nodeValue);
var theimageNode=itemNode.childNodes[1].firstChild.nodeValue;
quizItems[i].image = theimageNode;
var a=2;
// <answer> follows <question>
var answerNode=itemNode.childNodes[a++];

while (answerNode)
{
var isCorrectAnswer=false;
if (answerNode.attributes.correct=="y")
isCorrectAnswer=true;
trace(answerNode)
quizItems[i].addAnswer(answerNode.firstChild.nodeValue, isCorrectAnswer);
// goto the next <answer>

answerNode=itemNode.childNodes[a++];

}
i++;
}
gotoAndStop("Start");
}
var thequiz="reading.xml"
var quizItems=new Array();
var myData=new XML();
myData.ignoreWhite=true;
myData.onLoad=onQuizData;
//myData.load(xmlPath);
myData.load(thequiz);

stop();



FlashKit > Flash Help > Flash ActionScript
Posted on: 12-13-2006, 11:48 AM


View Complete Forum Thread with Replies

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

[XML Parsing] First Time Parsing.
Hi actionsript.org members,

It's my first time trying to parse xml and I've been stuck for a while.
I am trying to read the name of the first node in my xml file.

timeline, frame 1

Code:
var xml_file:XML = new XML();
xml_file.load("helloworld.xml");

//onLoad returns a boolean for failure/success
xml_file.onLoad = function(success:Boolean)
{
if (success)
trace("node name: " + xml_file.firstChild.nodeName);
else
trace("xml failed to load");
};
helloworld.xml

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<helloworld>Hello World!</helloworld>
output

Code:
node name: null

XML Parsing
Hi guys,
Check out this xml. When I try to get the node value of PARA , it throws out only "In order to be effective" but not the other part.
Any idea how I can get the content of the whole node value. I need help urgently. Thanks


-----------------------------------------------------
<ACTIVITY type='para' mode='word'>
<VERSION id='1.0'/>
<PARA>In order to be effective, a <CROSS.REFERENCE idref="ch01_memoir" alt.text="memoir"

format="bold" directive.type="term"/> must clearly locate the reader in place and time. In

the Reading Log version of the bracketed paragraph, highlight those words and phrases that

tell where and when the story takes place.
</PARA>
</ACTIVITY>
-----------------------------------------------------

Parsing
I am using a loadVars object to import text strings to be displayed in a text box. the text that i'm inporting has certian special characters trade marks, percent symbols, and such that i need to have displayed.

i need some way to get these characters back into the strings because they are removed on import. does any body have a parser that can do that, tip, tute?

thank you

XML Parsing
I try parse xml document with XML object functions (Flash 6.0)
All works great. Only i can't read property - nodeValue. All times return 'null'. I look nodeType and its equals '1' all times. Where is the problem?

P.S. I have not define DTD
P.S.S Sorry, but i speek english very bad.

Rss Parsing
Does anyone know an easy way to Parse Rss Files in flash?

XML Parsing
Hi
I hope to get some tips from you before I start coding my Flash application.
It is a map with city locations where my clients stores exists.

Te data is a XML file that is generated from an existing data base table.
and will look something like this

<stores>

<store>
<name>Store 1</name>
<adress>Adress ...</adress>
<city>New York</city>
</store>

<store>
<name>Store 2</name>
<adress>Adress ...</adress>
<city>New York</city>
<xcordinate>580</xcordinate>
<ycordinate>40</ycordinate>
</store>

<store>
<name>Store 3</name>
<adress>Adress ...</adress>
<city>San Francisco</city>
<xcordinate>25</xcordinate>
<ycordinate>49</ycordinate>
</store>
<store>
<name>Store 2</name>
<adress>Adress ...</adress>
<city>San Francisco</city>
<xcordinate>25</xcordinate>
<ycordinate>49</ycordinate>
</store>
</stores>

As you see there can be 2+ stores in one city( eg. here San Francisco)

On this map I first need to put a pin where the stores are located,
I would like to attach a pin movieclip, and place the x and y based on the x and ycordinate

But I don' t need to do that twice,
so how would I load the XML file and kind of sort out eg. San Francisco only once for this operation?

anyone who can give som clues/help

thanks in advance
T

XML Parsing
I want to parse the image names in the following XML into an array:

<?xml version="1.0" encoding="UTF-8" ?>
- <ride>
- <gallery>
<image>1_gallery_1.jpg</image>
<image>1_gallery_2.jpg</image>
<image>1_gallery_3.jpg</image>
<image>1_gallery_4.jpg</image>
<image>1_gallery_5.jpg</image>
<image>1_gallery_6.jpg</image>
<image>1_gallery_7.jpg</image>
<image>1_gallery_8.jpg</image>
</gallery>
</ride>

What would the variable name be to get to the start of the image names?

IE: this.firstChild.childNodes.childNodes[0].firstChild.nodeValue

I'm having a really hard time figuring this out.

[F8] XML Parsing
How might I store somthign like this in an array?
<event date="4" name="On Campus" text="Look for Zeta Psi Brothers on campus with their blue shirts. 11-3pm">

If the XML is filled with these, on for whatever day of that month.

XML Parsing Help
Hey guys,

just trying to grasp the e4x parsing, Im not sure what the best method would be to solve this:

I have an xml file with settings like this:
<?xml version="1.0" encoding="UTF-8" ?>
<settings ver='0.1'>
<menuSettings>
<textFace>_Arial</textFace>
</menuSettings>
<windowSettings>
<cornerSize>5</cornerSize>
<borderSize>4</borderSize>
</windowSettings>
</settings>

What I would like to do is loop through all of these settings, and set them, with something like:
var settings:Object = _settingsXML.windowSettings;
for (var o:Object in settings) {
WindowSettings["_"+o] = settings[o];
}
so it would set _cornerSize = 5 and _borderSize = 4 in the WindowSettings class.
If i made each node like this:
<setting name="cornerSize">5</setting>
I could loop through all the "setting" tags, but I want each node to be named the variable name.

I would imagine this is a simple task, I just havent been able to find what I need online. Let me know if you need more info or I am unclear on anything.

Thanks for your help!

Help With Parsing XML
could someone tell me what is wrong with my code? I cant figure it out :-(

XML:
Code:
<?xml version="1.0" encoding="utf-8"?>
<images>
<slide>
<src> http://www.sandradussault.com/xml/flash-images/01.jpg </src>
<caption> image 01 </caption>
</slide>
< /images>
AS3:

Code:
var xml:XML;
var slideinfo:XMLList;
var urlRequest:URLRequest = new URLRequest ("slideshow.xml");
var xmlLoader:URLLoader = new URLLoader();

function xmlLoaded(evt:Event):void {
xml = new XML (evt.target.data);
trace (xml);

}

xmlLoader.load(urlRequest);
xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

Parsing Css In As3
I'm working on a project where I need to load existing .css files in to flash. Not a big deal for text fields, but I need to figure out a way to use the hex value found in the css file for a background color, and in flash use setTransform to change the fill color of some mc's to that color. Anyone know how to pull a particular value out of an externally loaded css file in flash and store it as a value?

E4X Parsing
I have an XML file which is nested as many as 5 levels deep, for the life of me I cannot parse it correctly using the XMLList. I 'd like to use a function that wouls allow me to iterate through the XMLList based on an attribute's value and return the list containing the value. I've been at this for 4 hours now and cannot get it to work. I've seen examples but they are all 2 levels deep.

any help would be greatly appreciated!

Thanks

Parsing Help
Hey All, I have this var: myVariable_temp

I need to parse out everthing but myVariable and cut out the _temp. The _temp part can change too, ie., _temp1 or _temp2. Can anyone help me with this real quick?

Thanks, Dvl

Parsing Help
hi guys, i really need to learn how to parse but i'm ont getting the head or tail of it so if any of u outta there can explain it to me please do so

XML Parsing...
heya everyone!

How do I know if the XML file is fully parsed, I mean, everytime I run my project, the first time it shows 'undefined' on every dynamic text field, but as soon as it loops back it shows the text properly... I dont like to have 'undefined' on the first run... is there any way to avoid this??

thkx

XML Parsing
Hi, I am trying to parse an XML file, and well I a not so great at it...
Anyway here is the code I use...


HTML Code:
function loadXML(loaded){
if(loaded){
root = xmlData.firstChild;
trace(root.firstChild.nodeName);
trace(xmlData.childNodes.length);
for(var i = 0; i < xmlData.childNodes.length; i++){
var cname = root.childNodes[i].firstChild.nodeValue;
trace(cname);
myColor = new Color(cname);
myColor.setRGB(0xCCCCCC);
_root[cname].onRollOver = function(){
myColor = new Color(cname);
myColor.setRGB(0xFFFFFF);
}
_root[cname].onRollOut = function(){
myColor = new Color(cname);
myColor.setRGB(0xCCCCCC);
}
}
}else{
trace("file not loaded!");
}
}

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("countries.xml");
stop();
And here is the XML file code


HTML Code:
<?xml version="1.0"?>
<country>
<name>france</name>
</country>
<country>
<name>spain</name>
</country>
<country>
<name>italia</name>
</country>
The trace for the number of childNodes is fine and the for() seems to loop properly, but my cname variable is only right the first time it go through the for and then it give me "undefined"...

Anyone see what could go wrong here?

Thanks.

Parsing XML - Almost There
Ok, here is my question; I want to parse the below xml document and assign
the correct answer text to a variable for example the following node has a value of 8

<answer correct = 'y'>8</answer>


How do I identify that in my parsing function



Code:

<?xml version="1.0"?>
<quiz>
<title>Addition</title>
<items>
<item><question>What is 2 + 2=</question><theimage>Http://www.myURL.com</theimage><answer>6</answer><answer correct = 'y'>4</answer><answer>5</answer><answer>8</answer></item>
<item><question>What is 3 + 8=</question><theimage>Http://www.myURL.com</theimage><answer correct = 'y'>11</answer><answer>10</answer><answer>8</answer><answer>9</answer></item>
<item><question>What is 9 + 1 =</question><theimage>Http://www.myURL.com</theimage><answer>9</answer><answer correct = 'y'>10</answer><answer>7</answer><answer>8</answer></item>
<item><question>What is 4 + 4 =</question><theimage>Http://www.myURL.com</theimage><answer>5</answer><answer>6</answer><answer>7</answer><answer correct = 'y'>8</answer></item>
</items>
</quiz>












Code:

function onQuizData(success)
{
var quizNode=this.firstChild;
var quizTitleNode=quizNode.firstChild;
title=quizTitleNode.firstChild.nodeValue;

var i=0;
// <items> follows <title>
var itemsNode=quizNode.childNodes[1];
while (itemsNode.childNodes[i])
{
var itemNode=itemsNode.childNodes[i];
// <item> consists of <question> and one or more <answer>
// <question> always comes before <answer>s (node 0 of <item>)
var questionNode=itemNode.childNodes[0];
quizItems[i]=new QuizItem(questionNode.firstChild.nodeValue);
var theimageNode=itemNode.childNodes[1].firstChild.nodeValue;
quizItems[i].image = theimageNode;
var a=2;
// <answer> follows <question>
var answerNode=itemNode.childNodes[a++];

while (answerNode)
{
var isCorrectAnswer=false;
if (answerNode.attributes.correct=="y")
isCorrectAnswer=true;
trace(answerNode)
quizItems[i].addAnswer(answerNode.firstChild.nodeValue, isCorrectAnswer);
// goto the next <answer>

answerNode=itemNode.childNodes[a++];

}
i++;
}
gotoAndStop("Start");
}
var thequiz="reading.xml"
var quizItems=new Array();
var myData=new XML();
myData.ignoreWhite=true;
myData.onLoad=onQuizData;
//myData.load(xmlPath);
myData.load(thequiz);

stop();

Xml Parsing
Hey everyone,

I am in a bit of a pickle here with parsing an xml file. I will explain my xml file and give the code i am using.


Code:
<?xml version="1.0" encoding="UTF-8"?>
<images>
<member id="1">
<file>images/sample1.jpg</file>
<file>images/sample2.jpg</file>
<file>images/sample3.jpg</file>
<file>images/sample4.jpg</file>
</member>
<member id="2">
<file>images/member_2/sample1.jpg</file>
<file>images/member_2/sample2.jpg</file>
<file>images/member_2/sample3.jpg</file>
</member>
</images>

Code:
function loadImages():void
{
var urlreq:URLRequest = new URLRequest("images.xml");
var _xmlLoader:URLLoader = new URLLoader(urlreq);

_xmlLoader.addEventListener(Event.COMPLETE, xmlLoadComplete);
}

function xmlLoadComplete(event:Event):void
{
XML.ignoreWhitespace = true;
var images:XML = new XML(event.target.data);
var i:Number = 0;

_mainImageUrls = new Array(images.image.length());

for (i=0; i < images.member.length(); i++)
{
_mainImageUrls[i] = images.member[i].image[i].file.text();
}
}
As you can see from the xml the structure has changed and my code no longer works. what i need to be able to do is the following.

1. A variable will be passed from the html page. this will be the id of the member.
2. The xml will be parsed and the member's images with the matching id will be loaded into an array.

If someone could help me i would be so appreciated as there is very limited information about action script 3.0 at the moment. Thanks.

Xml Parsing Help
I am having problems parsing xml node.My xml node is as follows
<data>
<object>
<formItem>
<label>Dish</label>
<value>sweet</value>
<value>Spicy</value>
<controlType>RadioButton</controlType>
</formItem>
</object>
</data>

Now based on the number of <value> tag present i need to create radio buttons on the fly.May i know how to parse the following xml to create 2 radio buttons with labels sweet and spicy

XML Parsing
Hey all,
I have looked to try and find this answer. Let me know if you can figure out a trace statement to get the medium image URL. Thanks a bunch.

Code:
<track>
<name>Coffee</name>
<mbid/>
<url>www.last.fm/music/Aesop+Rock/_/Coffee</url>
<date uts="1219938000">28 Aug 2008, 15:40</date>
<artist>
<name>Aesop Rock</name>
<mbid>aba64937-3334-4c65-90a1-4e6b9d4d7ada</mbid>
<url>http://www.last.fm/music/Aesop+Rock</url>
</artist>
<image size="small">http://userserve-ak.last.fm/serve/34/3602622.jpg</image>
<image size="medium">http://userserve-ak.last.fm/serve/64/3602622.jpg</image>
<image size="large">http://userserve-ak.last.fm/serve/126/3602622.jpg</image>
</track>

XML Parsing
I have a thumbnail carousel that uses an external XML file, the site we are posting it to doesn't allow for external XML so I switched it to embedded XML. The code verifies but nothing is loaded, can you please take a look and see if there are any errors or give me direction on how to accomplish pulling the XML from a hidden text field as explained in the link below:

http://www.actionscript.org/forums/s....php3?t=122446



ActionScript Code:
import flash.filters.BlurFilter;
import mx.utils.Delegate;
class oxylus.carousel.Carousel extends MovieClip {
    private var node:XMLNode;
    private var _vertical:Boolean;
    private var _autoMove:Boolean;
    private var _speed:Number;
    private var _maxSpeed:Number;
    private var _radiusx:Number;
    private var _radiusy:Number;
    private var _stopOnRollover:Boolean;
    private var _allButtons:Boolean;
    private var _blurScale:Number;
    private var _hitW:Number;
    private var _hitH:Number;
    private var xml:XML;
    private var Thumbs:Array;
    private var refAngle:Number = 0;
    private var angle:Number;
    private var baseDepth:Number;
    private var once:Boolean = false;
    public function Carousel() {
        Thumbs = new Array();
        xml = new XML();
        xml.ignoreWhite = true;
        xml.onLoad = Delegate.create(this, dataLoaded);
        xml.parseXML("<?xml version="1.0"?>"+
                 "<carousel vertical="no" autoMove="no" maxSpeed="1" radiusX="145" radiusY="20" blurScale="8" reflections="yes" showBorder="yes" showTooltip="yes" stopOnRollover="yes" allButtons="no" hitAreaWidth="376" hitAreaHeight="300">"+
    "<image src="img/tony.jpg" tooltip="Tony's Story" link="http://www.youtube.com/watch?v=_cgrBatl4gU&feature=PlayList&p=AB9F86531A994FA9&index=16" target="_self" />"+
    "<image src="img/gwendolyn.jpg" tooltip="Gwendolyn's Story" link="http://www.youtube.com/watch?v=qm1kPpcw-RI&feature=PlayList&p=AB9F86531A994FA9&index=13" target="_self" />"+
    "<image src="img/angela.jpg" tooltip="Angela's Story" link="http://www.youtube.com/watch?v=0OwpVViTQm4&feature=PlayList&p=AB9F86531A994FA9&index=7" target="_self" />"+
    "<image src="img/elizabeth.jpg" tooltip="Elizabeth's Story" link="http://www.youtube.com/watch?v=s6pnxjFpmkU&feature=PlayList&p=AB9F86531A994FA9&index=1" target="_self" />"+
    "<image src="img/juanne.jpg" tooltip="Juanne's Story" link="http://www.youtube.com/watch?v=d79ouOG2A1U&feature=PlayList&p=AB9F86531A994FA9&index=0" target="_self" />"+
    "<image src="img/melissa.jpg" tooltip="Melissa's Story" link="http://www.youtube.com/watch?v=tCUtCTxdqtQ&feature=PlayList&p=AB9F86531A994FA9&index=29" target="_self" />"+
    "<image src="img/michael.jpg" tooltip="Michael's Story" link="http://www.youtube.com/watch?v=uoiVBJJkhbU&feature=PlayList&p=AB9F86531A994FA9&index=11" target="_self" />"+
    "<image src="img/jiro.jpg" tooltip="Jiro's Story" link="http://www.youtube.com/watch?v=USd1ggftg4U&feature=PlayList&p=AB9F86531A994FA9&index=4" target="_self" />"+
    "<image src="img/adam1.jpg" tooltip="Adam's Story" link="http://www.youtube.com/watch?v=NaURm0uxOZE&feature=PlayList&p=AB9F86531A994FA9&index=8" target="_self" />"+
    "<image src="img/linda.jpg" tooltip="Linda's Story" link="http://www.youtube.com/watch?v=YmKndZjg1Vw&feature=PlayList&p=AB9F86531A994FA9&index=3" target="_self" />"+
"<carousel>");
    }
    private function dataLoaded(s) {
        if (!s) {
            trace("Could not load xml ! Check xml (must be carousel.xml)");
            return;
        }
        node = xml.firstChild;
        _vertical = node.attributes.vertical == "yes";
        _autoMove = node.attributes.autoMove == "yes";
        _maxSpeed = _speed=Number(node.attributes.maxSpeed);
        _radiusx = Number(node.attributes.radiusX);
        _radiusy = Number(node.attributes.radiusY);
        _blurScale = Number(node.attributes.blurScale);
        _stopOnRollover = node.attributes.stopOnRollover == "yes";
        _allButtons = node.attributes.allButtons == "yes";
        _hitW = Number(node.attributes.hitAreaWidth)/2;
        _hitH = Number(node.attributes.hitAreaHeight)/2;
        _radiusx = Number(node.attributes.radiusX);
        //
        var p:XMLNode = node.firstChild;
        var i:Number = 0;
        baseDepth = this.getNextHighestDepth();
        for (; p != null; p=p.nextSibling, i++) {
            var tn:MovieClip = this.attachMovie("Thumbnail", "tn"+i, baseDepth+i);
            tn.setData(p, node);
            if (_stopOnRollover) {
                tn.onMouseOver = Delegate.create(this, Pause);
                tn.onMouseOut = Delegate.create(this, Resume);
            }
            Thumbs.push(tn);
            //break;
        }
        angle = 360/Thumbs.length;
        if (!_autoMove) {
            spin();
            this.onMouseMove = mouseMoveHandler;
        } else {
            Resume();
        }
    }
    private function Pause() {
        delete this.onEnterFrame;
    }
    private function Resume() {
        this.onEnterFrame = spin;
    }
    private function spin() {
        for (var i = 0; i<Thumbs.length; i++) {
            var tn:MovieClip = Thumbs[i];
            var crtAngle:Number = (refAngle+i*angle)%360;
            if (crtAngle<0) {
                crtAngle += 360;
            }
            if (_vertical) {
                tn._x = Math.sin((crtAngle)/180*Math.PI)*_radiusy;
                tn._y = Math.cos((crtAngle)/180*Math.PI)*_radiusx;
            } else {
                tn._y = Math.sin((crtAngle)/180*Math.PI)*_radiusy;
                tn._x = Math.cos((crtAngle)/180*Math.PI)*_radiusx;
            }
            //
            var tAngle:Number = (crtAngle+90)%360;
            if (tAngle>180) {
                tAngle = 360-tAngle;
            }
            var minScale:Number = 50;
            var minAlpha:Number = 30;
            tn._xscale = tn._yscale=minScale+(100-minScale)*tAngle/180;
            var lim:Number = 90;
            if (tAngle<=lim) {
                tn.filters = blur(_blurScale-_blurScale*tAngle/lim);
                tn._alpha = minAlpha+(100-minAlpha)*tAngle/lim;
            } else {
                tn.filters = blur[0];
                tn._alpha = 100;
            }
            var crtDepth:Number = baseDepth+Math.floor(2*tAngle/angle);
            if (tn.getDepth() != crtDepth) {
                tn.swapDepths(crtDepth);
            }
            if (!_allButtons) {
                tn.enabled = tAngle>=90;
            }
        }
        refAngle += _speed;
    }
    private function blur(blur) {
        blur = Math.round(blur);
        if (blur<1) {
            return [];
        }
        return [new BlurFilter(blur, blur, 2)];
    }
    private function mouseMoveHandler() {
        if (_xmouse<-_hitW || _xmouse>_hitW || _ymouse<-_hitH || _ymouse>_hitH) {
            return;
        }
        if (!once) {
            once = true;
            Resume();
        }
        if (!_vertical) {
            _speed = _maxSpeed*_xmouse/_hitW;
        } else {
            _speed = _maxSpeed*_ymouse/_hitH;
        }
    }
}

Parsing XML
This is my XML

<BOOKMARKS>
<BOOKMARK01 NAME="SLIDE01"
NUMBER="1"/>
<BOOKMARK02 NAME="SLIDE05"
NUMBER="5"/>
<BOOKMARK03 NAME="SLIDE10"
NUMBER="10"/>
<BOOKMARK04 NAME="SLIDE15"
NUMBER="15"/>
<BOOKMARK05 NAME="SLIDE20"
NUMBER="20"/>
</BOOKMARKS>

Here is my Flash (so far)


ActionScript Code:
bookmarkXML = new XML();
bookmarkXML.load("slide_list.xml");
bookmarkXML.onLoad = function(success){
    if(success){
        trace("Loaded");
    }else{
        trace("Not Loaded");
    }
}

The goal is to have two seperate arrays, one for Name, one for Number. How to do this?

-mrand01

Parsing
I was unable to find any tutorial which teaches on string parsing in action script... Why is that? Can any one tell me some handy functions to use?

Parsing Xml
i am creating a blog using actionscript and php...
when i load the xml file characters like apostrophes are replaced with &apos; is there way to keep this from happening??
i have the php upload the text from a swf file, at first it was adding slashes in front of the characters like aposthrophes, so i used the stripslashes function and now im getting the current problem...
any advice or solutions would be greatly appreciated...

Parsing KML / XML
I'm aiming to integrate KML geodata. Why won't this work? I just want to create one Node for each <placemark> tag in the xml.

the xmlData trace gets:

<kml xmlns="

How Do I Parsing Xml
This how my customers xml is coming across and can not change.
<month name="January">
<day>
<date>01</date>
<name>Thursday</name>
<time>12:03 PM</time>
<comment>It is a hot day</comment>
</day>
<day>
<date>05</date>
<name>Monday</name>
<time>09:28 AM</time>
<comment>Another hot day</comment>
</day>
</month>

The above data structure uses a new node for each bit of core information. It is well laid out and very readable by humans, however a better structure exists when using Flash. The data structure below makes more use of the attributes feature, speeding the parsing process up. It takes longer for Flash to read 6 separate nodes, than it does 6 attributes of a node. The data structure below is suited better for use with Flash.

How do I get it formated like this?
<month name="January">
<day date="01" name="Thursday" time="12:03 PM" comment="It is a hot day" />
<day date="05" name="Monday" time="09:28 AM" comment="Another hot day" />
</month>

Parsing Help
Claudio helped me out a few weeks ago, and it worked great.

I'm having some more trouble parsing data.

The string is being passed in as so:
DefaultValueList=DefaultValue10="Caption 1 Text",DefaultValue11="Some text";

my code is

ActionScript Code:
//assuming flash already has the stringDefaultValueList=DefaultValue10="Caption 1 Text",DefaultValue11="Some text";//var receivedData = {vars:new Array(), datas:new Array()};function Parse() {    var temp1 = _level0.DefaultValueList.split(",");    for (var i = 0; i<temp1.length; ++i) {        var temp2 = temp1[i].split("=");        receivedData.vars.push(temp2[0]);        receivedData.datas.push(temp2[1]);    }    trace(receivedData.vars+newline+receivedData.datas);}Parse();


Help is much appreciated

Parsing Help
Ok new situtation for me here.

I have yet another string being passed into me. Looks like this:

Code:
DefaultValueList=1=,22=,8=image100414.jpg,,Beautiful House,15=,16=,17=,3=image100428.jpg,7=NoBalloon.jpg,,,Balloon.jpg,,,12=,13=,14=,21=,2=,23=,4=HouseList,11=,10=,18=,19=,20=,9=FixedImageSignatureCIFile.jpg,,Script,5=HouseList
Now eventually 1,22,15, etc. will have values. I need to reference these value's later on in my movie.

How can I set let's say 1 to a variable?

Heres the code Im working with

ActionScript Code:
loadASP = new LoadVars();loadASP.load("http://pod.one2onemail.com/One2OneMail/ParameterFolder/myshopcart.txt");loadASP.onLoad = function(success) {    if (success) {        DefaultValueList = this.DefaultValueList;        Host = this.Host;        _root.Parse();    } else {        trace("communication broken");    }    if (DefaultValueList="") {        trace("Wasn't Edited Yet");    } else {        trace("Was Edited");    }};var receivedData = {photos:new Array(), texts:new Array(), folders:new Array(), captions:new Array()};function Parse() {    //var temp1 = DefaultValueList.split("+++");    var temp1 = DefaultValueList.split("+++");//someVar = "1=+++22=+++8=image100414.jpg::Beautiful House+++15=+++16=+++17=+++3=image100428.jpg+++7=NoBalloon.jpg::~Balloon.jpg::+++12=+++13=+++14=+++21=+++2=+++23=+++4=HouseList+++11=+++10=+++18=+++19=+++20=+++9=FixedImageSignatureCIFile.jpg::Script";//someVar = "DefaultPageNumber=1&VersionName=test392658328&UserID=test3&Host=one2onemail.com&WebsiteDatabaseName=One2OneMail&PartNumber=PC101&DefaultValueList=1=+++22=+++var8=image100414.jpg::Beautiful House+++15=+++16=+++17=+++&var3=image100428.jpg+++7=NoBalloon.jpg::~Balloon.jpg::+++12=+++13=+++14=+++21=+++2=+++23=+++4=HouseList+++11=+++10=+++18=+++19=+++20=+++9=FixedImageSignatureCIFile.jpg::Script+++5=HouseList+++6=HouseList++&FName1=HouseList&FType1=Image&DefaultValue1=image100439.jpg:New Brunswick:Beautiful House~image100440.jpg:New Brunswick:OK House~image100431.jpg:New Brunswick:Average House~image100427.jpg::~image100428.jpg::~image100430.jpg:New Brunswick:Beautiful House~image100432.jpg:New Brunswick:Beautiful House~image100433.jpg:New Brunswick:Beautiful House~image100434.jpg:New Brunswick:Beautiful House~image100435.jpg:New Brunswick:Beautiful House~image100436.jpg:New Brunswick:Beautiful House~image100437.jpg:New Brunswick:Beautiful House~image100438.jpg:New Brunswick:Beautiful House&DV_Type1=ValueListNo&CanEdit1=YES&Derr1=&FName2=CaptionList&FType2=Text&DefaultValue2=3602 Riddle Lane Single Family~WINTER LANDSCAPE~10 Sidney Road~500 NEWTOWN ROAD~300 MORRIS AVE~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family~3602 Riddle Lane Single Family&DV_Type2=ValueListNo&CanEdit2=YES&Derr2=&FName3=Image_1&FType3=Image&DefaultValue3=image100428.jpg&DV_Type3=FromDef&CanEdit3=YES&Derr3=1&FName4=Image_2&FType4=Image&DefaultValue4=HouseList&DV_Type4=FromDef&CanEdit4=YES&Derr4=1&FName5=Image_3&FType5=Image&DefaultValue5=HouseList&DV_Type5=FromDef&CanEdit5=YES&Derr5=1&FName6=Image_4&FType6=Image&DefaultValue6=HouseList&DV_Type6=FromDef&CanEdit6=YES&Derr6=1&FName7=Image_5&FType7=Image&DefaultValue7=NoBalloon.jpg::~Balloon.jpg::&DV_Type7=ValueListNo&CanEdit7=YES&Derr7=&FName8=Image_6&FType8=Image&DefaultValue8=image100414.jpg::Beautiful House&DV_Type8=ValueListShow&CanEdit8=YES&Derr8=&FName9=Image_7&FType9=Image&DefaultValue9=FixedImageSignatureCIFile.jpg::Script&DV_Type9=ValueListShow&CanEdit9=YES&Derr9=&FName10=TextField_1&FType10=Text&DefaultValue10=CaptionList&DV_Type10=FromDef&CanEdit10=YES&Derr10=2&FName11=TextField_2&FType11=Text&DefaultValue11=CaptionList&DV_Type11=FromDef&CanEdit11=YES&Derr11=2&FName12=TextField_3&FType12=Text&DefaultValue12=CaptionList&DV_Type12=FromDef&CanEdit12=YES&Derr12=2&FName13=TextField_4&FType13=Text&DefaultValue13=CaptionList&DV_Type13=FromDef&CanEdit13=YES&Derr13=2&FName14=TextField_5&FType14=Text&DefaultValue14=&DV_Type14=Static&CanEdit14=YES&Derr14=&FName15=TextField_6&FType15=Text&DefaultValue15=Listed~Sold&DV_Type15=ValueListNo&CanEdit15=NO&Derr15=&FName16=TextField_6A&FType16=Text&DefaultValue16=~Faster,<BR>Easier!&DV_Type16=DataOnly&CanEdit16=NO&Derr16=15&FName17=TextField_6B&FType17=Text&DefaultValue17=~Great <BR>Price!&DV_Type17=DataOnly&CanEdit17=NO&Derr17=15&FName18=TextField_7&FType18=Text&DefaultValue18=&DV_Type18=Static&CanEdit18=YES&Derr18=&FName19=TextField_8&FType19=Text&DefaultValue19=&DV_Type19=Static&CanEdit19=YES&Derr19=&FName20=TextField_9&FType20=Text&DefaultValue20=&DV_Type20=Static&CanEdit20=YES&Derr20=&FName21=TextField_10&FType21=Text&DefaultValue21=&DV_Type21=Static&CanEdit21=YES&Derr21=&FName22=Image_8&FType22=Image&DefaultValue22=Remax.jpg::&DV_Type22=Static&CanEdit22=NO&Derr22=&FName23=ColorScheme&FType23=TemplateDefined&DefaultValue23=&DV_Type23=Static&CanEdit23=YES&Derr23=";    var temp1 = DefaultValueList.split("+++");    for (var i = 0; i<temp1.length; ++i) {        var temp2 = temp1[i].split("~");        for (var j = 0; j<temp2.length; j++) {            var temp3 = temp2[j].split(":");            for (var k = 0; k<temp3.length; k++) {                receivedData.photos.push(temp3[k]);            }        }    }    trace("Variables are: "+receivedData.photos);}


Thanks a bunch!

Parsing XML Help, PLEASE...
If this is my XML doc. (named print.xml)
<print>
<thumb01>
<client>"Quantico"</client>
<thumb>thumb01.jpg</thumb>
</thumb01>
</print>

and this is my Actionscript
printXML = new XML();
printXML.ignoreWhite = true;
printXML.load("print.xml");
printXML.onLoad = function(success) {
var thumb01 = printXML.firstChild.firstChild;
trace(thumb01.firstChild.nodeType);
//trace(this.firstChild.childNodes);
_root.clientTXT.text = printXML.firstChild.firstChild.firstChild.nodeValu e;
_root.thumb01.thumbHolder.loadMovie(this.firstChil d.firstChild.thumb);
};


I can work just fine calling text documents to text fields, and dynamically loading images just using loadMovie("url" , holder);

But I really want to start using XML so I have a one stop shop for all changes.

Any help would greatly be appreciated... I've gone through most of the Kirupa XML tutorial, but I need it at it's most basic level...

I can get text fields to populate when using an Attribute of a childNode
<child name="frank">

I can parse using:
myText.text = myXML.firstChild.attribute.name;

but I can't get:
<child>
<name> frank </name>
</child>

to parse...

Help help help...
please...

send me a simple FLA that works, nothing that autopopulates thumbnails, etc. Just a simple simple parse, of simple XML.

Thanks!!

XML Parsing Help
I have the following xml file from which i need to extract "id's" of the elements in the "slides":


Code:
<?xml version="1.0"?>
<smil xmlns="http://www.w3.org/2001/SMIL20/Language"

xmlns:rn="http://features.real.com/2001/SMIL20/Extensions">

<head>
<meta name="base" content="../01_Uvod_01/" />

<layout>

<root-layout id="Player-Window" backgroundColor="black" width="800" height="500"/>

<region id="main" left="295" width="458" top="35" height="343" fit="meet"/>
<region id="subs" left="265" width="520" top="440" height="50"/>
<region id="links" left="45" width="150" top="70" height="180"/>
<region id="video" left="48" width="160" top="330" height="125" fit="meet"/>
</layout>

</head>
<body>
<par title="Uvod u otvoreno racunarstvo">

<!--slides-->
<img id="slide2" region="main" begin="slideCopyright.end-1s" dur="0:13" src="../Shared/glagoljica.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide3" region="main" begin="slide2.end-1s" dur="0:09" src="Graphic/slide03.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide4" region="main" begin="slide3.end-1s" dur="0:34" src="Graphic/slide04.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide5" region="main" begin="slide4.end-1s" dur="0:50" src="Graphic/slide05.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide6" region="main" begin="slide5.end-1s" dur="0:20" src="Graphic/slide06.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide7a" region="main" begin="slide6.end-1s" dur="0:20" src="Graphic/slide07.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide10" region="main" begin="slide7a.end-1s" dur="0:19" src="Graphic/slide10.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide7b" region="main" begin="slide10.end-1s" dur="0:30" src="Graphic/slide07.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide8" region="main" begin="slide7b.end-1s" dur="0:39" src="Graphic/slide08.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide9" region="main" begin="slide8.end-1s" dur="0:55" src="Graphic/slide09.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center" transOut="tfade"/>
<img id="slide10b" region="main" begin="slide9.end-1s" end="audio1.end-0.1s" src="Graphic/slide10.gif" fill="remove" transIn="tfade" regPoint="center" regAlign="center"/>

</par>

</body>

</smil>
And here is xml loading code:


Code:
var myXML:XML = new XML();
var XML_URL: String = "example.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);

myLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded (eventObj:Event):void{
myXML = new XML(myLoader.data);
trace ("XML Loaded");
}
But i just can't find the way to access "slides" part of xml so if anyone can help me out i would really appreciate it.

thanks

Parsing XML
Hey guys, got a question for you.

I have an XML document that looks like this:


HTML Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<buildYourOwnItems>
<!-- BASE -->
<item name="base">
<name>base</name>
<thumb>gfx/thumbs/base.png</thumb>
<image>gfx/base.png</image>
<price>$7000</price>
</item>
<!-- STEEL TABLES -->
<item name="table1">
<name>table1</name>
<thumb>gfx/thumbs/table1.png</thumb>
<image>gfx/table1.png</image>
<price>$7000</price>
</item>
</buildYourOwnItems>
I want to parse this in Actionscript3. I can return the attributes (name="base"), but cannot receive the values of just the nodes. When I use this code:


PHP Code:



loader.load(req);loader.addEventListener("complete", init);function init(e:Event){  doc.ignoreWhite = true;  xml = XML(loader.data);  doc.parseXML(xml.toXMLString());  for(var i = 0; i<doc.firstChild.childNodes.length; i++){    //trace(doc.firstChild.childNodes[i].attributes.name);    trace(doc.firstChild.childNodes[i].firstChild);      }} 




(The commented line would return the attribute)

I get the full tag. How can I isolate just the node value??

Thanks!

-theonlycarmire

XML Parsing?
Hello everyone,

I've got a problem completing a project of mine.
Firstly I am using the following XML:

Code:
<News>
<newsContent>
<title>My title here</title>
<date>My date here</date>
<content>My text here.</content>
<image>My Image here.jpg</image>
</newsContent>
</News>
I successfully load this xml into flash,but what I want to implement is when I click on a button for example "next" button,I want it to change the xml content(new image/title/date text).

I think I must create a second Node(<newsContent>) and change everything there,the image title text and date,but I don't know how to say flash to go to the next node when I click on a button.
Any suggestions?

Thanks in advance

Parsing XML
Hello

What does * do while parsing an XML node like the example given below


for (var i:int=0; i < xml.*.length(); i++)
{
var nam:String=xml.*[i].@name;
var upOutColor:uint=xml.*[i].@upOutColor;

}

Parsing XML
I'm trying to parse an XML file that gets returned by a server, but I can't get anything to work! I load it successfully into an XML variable, but then any attempt to parse it out fails... I'm assuming that I'm missing some fairly simple steps/concepts here, but it has me stumped and frustrated!

Here's a sample bit of the XML file: ......

Parsing Help
Claudio helped me out a few weeks ago, and it worked great.

I'm having some more trouble parsing data.

The string is being passed in as so:
DefaultValueList=DefaultValue10="Caption 1 Text",DefaultValue11="Some text";

my code is

ActionScript Code:
//assuming flash already has the stringDefaultValueList=DefaultValue10="Caption 1 Text",DefaultValue11="Some text";//var receivedData = {vars:new Array(), datas:new Array()};function Parse() {    var temp1 = _level0.DefaultValueList.split(",");    for (var i = 0; i<temp1.length; ++i) {        var temp2 = temp1[i].split("=");        receivedData.vars.push(temp2[0]);        receivedData.datas.push(temp2[1]);    }    trace(receivedData.vars+newline+receivedData.datas);}Parse();


Help is much appreciated

Parsing XML In F9
So I was able to get the XML to load. Now I need to use it and I'm having trouble with that.

Here's my current code.


ActionScript Code:
var myXML:XML = new XML();
myXML.ignoreComments = true;
myXML.ignoreWhitespace = true;
var XML_URL:String = "songList.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);
 
function xmlLoaded(evtObj:Event) {
       myXML = XML(myLoader.data);
       var nodesArray:Array = new Array(myXML.children());
       trace(nodesArray.length);
}


Shouldn't it be output of 3?

When I issue the trace command all it outputs is a number 1.

here's my XML


ActionScript Code:
<?xml version="1.0" encoding="UTF-8"?>
<songs>
    <song url="song1.mp3" />
    <song url="song2.mp3" />
    <song url="song3.mp3" />
</songs>

Help Parsing This...
I have some XML code that I need to parse into a flash movie and then render the date, news, headline, news content, and link to screen. I wanted to create an array but was thinking it might be redundant to do it this way then, I thought maybe creating an object might be the way to go... as a NewsBuilder Class that creates News Objects that contain the data as values of the properties. In this way I could access the data in my flash movie such as
Code:
news.id.date or news.id.description
I have tried to write the parser but have had no luck... can someone help...

Thanks...


Code:
<newsItems httpHost="">

<newsBatch id="2003.05">

<item date="05.28.2003">
<header>News Headline</header>
<description>
<point div_align="justify" suffBR="2">
<text>News Item Description</text>
</point>
<point>
<links>
<link href="somepage.html"/>
</links>
</point>
</description>
</item>

<item date="05.25.2003">
<header>News Headline</header>
<description>
<point div_align="justify" suffBR="2">
<text>News Item Description</text>
</point>
<point>
<links>
<link href="somepage.html"/>
</links>
</point>
</description>
</item>

</newsBatch>

<newsBatch id="2003.04">

<item date="04.218.2003">
<header>News Headline</header>
<description>
<point div_align="justify" suffBR="2">
<text>News Item Description</text>
</point>
<point>
<links>
<link href="somepage.html"/>
</links>
</point>
</description>
</item>

<item date="04.10.2003">
<header>News Headline</header>
<description>
<point div_align="justify" suffBR="2">
<text>News Item Description</text>
</point>
<point>
<links>
<link href="somepage.html"/>
</links>
</point>
</description>
</item>

</newsBatch>

</newsItems>

Parsing Xml Through Php
Hi. I am loading images from a database into a sprite. This all worked very well, but now when i've created the xml within a php script, i get an error.

TypeError: Error #2007: Parameter url must be non-null.



My php/xml looks like this
Code:

<?PHP

include ("databaseinfo");

/*connect to database*/
$query = 'SELECT * FROM shows ORDER BY startdate LIMIT 1';
$results = mysql_query($query, $db);

/*start xml*/
echo "<?xml version="1.0" ?>
";

echo "<slideshow>
";

while($row = mysql_fetch_row($results)) {
   echo "<photo url="http://www.d41249.monline.dk/images/$row[21]" caption="$row[1]" />
";
}

echo "</slideshow>
";


mysql_close($db);

?>



and my actionscript

Code:

private function loadContent():void {
         urlRequest = new URLRequest("cms/slideshow.php");
         urlLoader = new URLLoader();
         urlLoader.addEventListener(Event.COMPLETE, completeListener);
         urlLoader.load(urlRequest);
      }
      public function completeListener(e:Event):void {
         xmlData = new XML(urlLoader.data);
         xmlData.ignoreWhitespace = true;

         jpgLoader = new Loader();
         theURL = xmlData.attribute("photo url")[0];
         jpgRequest = new URLRequest(theURL);
         jpgLoader.load(jpgRequest);

         fakeHolder=new Sprite();
         fakeHolder.addChild(jpgLoader);
         fakeHolder.addEventListener(MouseEvent.MOUSE_OVER, addBox);
         addChild(fakeHolder);
         
      }

For some odd reason i keep getting the error and i cant seem to figure out why.

Can anyone see what i've done wrong or if i'm missing out some important details?

Cheers

XML Parsing
Todd this is great. I'm walking real slow through this, but can use this alot with what I have to do.

I get the undefined trace output you were referring to below.

"If any of these trace as "undefined" then you've got a problem, probably with either the naming of the fields in the XML or a mismatch between the Array varaible names. Once you get all the traced messages working you can delete the trace commands."

Here is my //XML PARSING

z.onLoad = function(success:Boolean) {
if (success) {
var photos:Array = new Array;
photos = this.firstChild.childNodes;
for (i=0; i<photos.length; i++) {
images.push(photos[i].attributes.images);
trace("Image#"+i+" = "+images[i]);//Remove once sucessfully checked
thumbs.push(photos[i].attributes.thumbs);
trace("Thumbnail#"+i+" = "+images[i]);//Remove once sucessfully checked
dur.push(photos[i].attributes.hold);
trace("Duration#"+i+" = "+images[i]);//Remove once sucessfully checked
}
loadThumb(tcount);

}
}

z.load ("list.xml"); Code:


Here is my Arrays

var images:Array = new Array;//Holds URLs of Main Images
var dur:Array = new Array;//Holds Duration variable for automatic show
var thumbs:Array = new Array;//Holds URLs of thumbnail Images
var tcount:Number = 0;//Counting Variable for Thumbnails
var isPlaying:Boolean = true;//Keeps track of automatic advancing images
var maskY:Number = 235.9;//Y coordinate for Scrolling Panel
var maskX:Number = 43;//X coordinate for Scrolling Panel
var thumbPad:Number = 3;//Pixel Space between thumbnails

Here is my XML code

<?xml version="1.0" encoding="ISO-8859-1"?>
<slideshow>
<photo url="images/image001.png" thumbs="images/thumb001.gif" hold="3" />
<photo url="images/image002.png" thumbs="images/thumb002.gif" hold="3" />
<photo url="images/image003.png" thumbs="images/thumb003.gif" hold="3" />
<photo url="images/image004.png" thumbs="images/thumb004.gif" hold="3" />
<photo url="images/image005.png" thumbs="images/thumb005.gif" hold="3" />
<photo url="images/image006.png" thumbs="images/thumb006.gif" hold="3" />
<photo url="images/image007.png" thumbs="images/thumb007.gif" hold="3" />
<photo url="images/image008.png" thumbs="images/thumb008.gif" hold="3" />
</slideshow>

Any suggestions? Thanks a ton!

Parsing Through XML
Hello...

Fair warning: I'm just starting out with XML (and Flash in general for that matter)

So, after much headache, I've finally been able to understand the basics of XML and Flash.

I've managed to put this peice of code together (forgive the messiness please). The code itself works perfectly. But I'm having problems with the next step.

Code:

function loadImages() {
for (i=1;i<9;i++) {
  var node = parent.childNodes[showing];
  var siteName = node.childNodes[i-1].firstChild.nodeValue
  var captionText = node.childNodes[i-1].attributes.description
  var tmpClip:MovieClip = eval("thumb" + i);
  tmpClip.id = i;
  tmpClip.onRelease = function() {
     var imgurl= parent.childNodes[showing]
     var linkurl = imgurl.childNodes[this.id - 1].attributes.url
     getURL(linkurl, _blank);
  }
  var tmpText:TextField = eval("siteName" + i);
  var tmpCaption:TextField = eval("caption" + i); 
  tmpText.text = siteName;
  tmpCaption.text = captionText;
  tmpClip.Holder.loadMovie(node.childNodes[i-1].attributes.thumb)
  if (node.childNodes.length >  i) {
     btn_next._visible = true;
     }
    else {
   btn_next._visible = false;
   }

  }
}

My next step is to define the "next" function. I want it so that if there are more than 8 nodes (i think they're called nodes) in the XML, clicking the next button will advance the images loaded into flash (along with the captions & links which are also brought in through the XML).

I've tried playing with the constraints on the for loop but some of my other varaibles are contingent on those contraints so that didn't pan through. I also tried some other loopy tricks which didn't work.

Thanks for the help.

String Parsing Help...
Is it possible to detect a carriage return in a string? I've tried using substring, looking for "
" (with one char and two), but I can't get it to work. Any ideas?

B

Parsing Strings
i have a variable
varHello = "90,23,43,42,64"
how can i split it up?

Parsing Variables Between Swf's?
Hi,

I am trying to parse variables set from one swf to another. How can this be done?

My main movie defines which button has been pressed and is given a text value ie btn_value = "home".

When the other swf is loaded I need it to read that variable to determine which frame to go to, but it doesn't seem to play ball.

This is probably really simple, but can someone remind me please? I had a late night last night!

Thanks.

Parsing Variables
Can anyone point me in the direction of a tutorial or article on parsing variables in Actionscript?? I've looked around, but haven't found any good one's yet.

Thanks!!

Parsing An <a> Tag In A String.
I want to take a string that will be in a dynamic text field that looks something like:

Code:
This is <b>my</b> text.<br /> Here is a <a href="some.htm">link</a>.
I want to take and parse the string and make it look like this:

Code:
This is <b>my</b> text.<br /> Here is a <font color="#FF0000"><a href="some.htm">link</a></font>.
As you can see I just want to wrap a font tag around the <a> tag to make the link a different color in the text field. I have a javascript that does something like this but not quite and I am having some issues. Can anyone help?

Oh and an off the subject question (that can't seem to be fully answered anywhere) can you make a a link change color on rollover in a dynamic text field? Got a url or fla? Thanks!

Parsing An <a> Tag In A String.
I want to take a string that will be in a dynamic text field that looks something like:

NOTE: *'s to keep the tags from not showing - ignore them please.


Code:
This is <*b*>my<*/b*> text.<*br /*> Here is a <*a href="some.htm"*>link<*/a*>.
I want to take and parse the string and make it look like this:

Code:
This is <*b*>my<*/b*> text.<*br /*> Here is a <*font color="#FF0000"*><*a href="some.htm"*>link<*/a*><*/font*>.
As you can see I just want to wrap a font tag around the <a> tag to make the link a different color in the text field. I have a javascript that does something like this but not quite and I am having some issues. Can anyone help?

Oh and an off the subject question (that can't seem to be fully answered anywhere) can you make a a link change color on rollover in a dynamic text field? Got a url or fla? Thanks!

Parsing Data
I have about 1300 student ID #'s that I want to put into an array. Unfortunatly, I cannot get them comma deliminated, all I have is a bunch of student ID's like so

"902131""887874""945489""954593""903913""90153 1"

what would be the best way to seperate these into an array?

Parsing Data
Ok, I have a canumdrum... the lame program I am using will not export data right all it gives me is about 1400 lines of this

923681,801-344-5213
913459,801-226-7563
914001,801-224-5708
907688,801-226-2650
901443,801-225-0364
918293,801-785-6681

I want to put this information into an array, but I am missing a comma after the phone number, I could manually go in and type comma a thousand times or so, but I want to know to code to parse this in case I need to again. Any idea's on how to get all the document to look like this?

923681,801-344-5213,913459,801-226-7563,914001,801-224-5708

Parsing XML In Flash
i just started messing around with parsing xml files today in flash. it's not really as hard as i thought, but i was wondering if anyone has any easier/better techniques of going about parsing an xml file. i'm creating a game and the process i'm having to go through to get the information keeps getting longer and longer... i'm wondering what would be easier. here is the process i go through, and this is just an example of one topic, and 5 questions with 3 possible answers for each... the xml file actually gets alot more complicated:


Code:
function loadMe() {
//show episode 1's information
trace("-------------------------");
trace("Episode 1 = " + level2Child.attributes["name"]);
trace("Topic 1 = " + level3Child.attributes["name"]);
trace("Question 1 = " + level4Child.attributes["name"]);
trace("Answer 1 = " + level6Child.nodeValue + ", Correct = " + level5Child.attributes["correct"]);
trace("Answer 2 = " + level5Child.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.attributes["correct"]);
trace("Answer 3 = " + level5Child.nextSibling.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.nextSibling.attributes["correct"]);
trace("Question 2 = " + level4Child.nextSibling.attributes["name"]);
trace("Answer 1 = " + level6Child.nodeValue + ", Correct = " + level5Child.attributes["correct"]);
trace("Answer 2 = " + level5Child.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.attributes["correct"]);
trace("Answer 3 = " + level5Child.nextSibling.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.nextSibling.attributes["correct"]);
trace("Question 3 = " + level4Child.nextSibling.nextSibling.attributes["name"]);
trace("Answer 1 = " + level6Child.nodeValue + ", Correct = " + level5Child.attributes["correct"]);
trace("Answer 2 = " + level5Child.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.attributes["correct"]);
trace("Answer 3 = " + level5Child.nextSibling.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.nextSibling.attributes["correct"]);
trace("Question 4 = " + level4Child.nextSibling.nextSibling.nextSibling.attributes["name"]);
trace("Answer 1 = " + level6Child.nodeValue + ", Correct = " + level5Child.attributes["correct"]);
trace("Answer 2 = " + level5Child.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.attributes["correct"]);
trace("Answer 3 = " + level5Child.nextSibling.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.nextSibling.attributes["correct"]);
trace("Question 5 = " + level4Child.nextSibling.nextSibling.nextSibling.nextSibling.attributes["name"]);
trace("Answer 1 = " + level6Child.nodeValue + ", Correct = " + level5Child.attributes["correct"]);
trace("Answer 2 = " + level5Child.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.attributes["correct"]);
trace("Answer 3 = " + level5Child.nextSibling.nextSibling.firstChild.nodeValue + ", Correct = " + level5Child.nextSibling.nextSibling.attributes["correct"]);
}

myXML = new XML();
myXML.ignoreWhite = true;
myXML.onLoad = loadMe;
myXML.load("myfile.xml");
as you can see, it adds up quickly, and actually... the Answers are the same because i'm stuck on how to get at the other answers to the questions that are embedded in these other questions. i'll keep messing with it, but i thought i'd post this to help anyone out and to also see if there is a better way to get this info. thanks!

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