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




Help With Parsing Strings



I need help with parsing strings to numbers.this is the phpscript.php
Code:
<html><body><?php $total=27; ?><form><input type="hidden" value=<?php echo "&total=$total&"; ?>></form></body><html>
this is the actionscript:
Code:
//loads variablesloadData = new LoadVars();loadData.load("phpscript.php");// when onload do functionloadData.onLoad = function (){ mytotal = Number(this.total);}
it gives me a NaN. Please help and tell me whats wrong.



ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 03-31-2006, 01:24 AM


View Complete Forum Thread with Replies

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

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

Parsing XML - It's All Strings?
I've got XML that's descriptions and numbers:

Code:
<myItem>
<campID>Amex: Inside</campID>
<desc>Amex over-the-page execution.</desc>
<otp>1</otp>
<swf1Url>amex/inside_oob_070104.swf</swf1Url>
<inpageW>300</inpageW>
<inpageH>250</inpageH>
<xPos>-468</xPos>
</myItem>
And here's the code that parses it:

Code:
function processWx(xmlDoc_xml){
xD = xmlDoc_xml;
for(i=0; i<xD.firstChild.childNodes.length; i++){
// start a new object;
aCamp[i] = new campaign();
aCamp[i].campNum = i;
for(j=0;j<xD.firstChild.childNodes[i].childNodes.length; j++){
var itemName =xD.firstChild.childNodes[i].childNodes[j].nodeName;
var itemVal =xD.firstChild.childNodes[i].childNodes[j].firstChild;
aCamp[i][itemName] = itemVal;
}
}
loaded=true;
}
The problem is that all the numbers are being imported as strings, (the itemVal). I've tried escaping them, but then the minus sign gets converted into something freaky. What am I doing wrong?

[AS3] Using Regular Expressions For Parsing Strings
Hi there, i am experimenting with parsing textfiles into different formats, and found the regular expressions in AS3 which should do the job. The problem is, i dont understand how it works.. Could anyone help me on this? The examples below are just to show the sort of function i am looking for (to start with).


Code:
<P ALIGN="LEFT"><FONT FACE="Arial" >this is a test</FONT></P>

Code:
[f1=arial][F1]this is a test[/f]

Prob With Comparing Utf-8 Enc Loaded Strings With Other Strings
I load a bunch of strings from a MySQL database. Those strings have been utf-8 encoded before being put there. When I load one of the strings and compare with a string defined inside flash it works great as long as the string doesnt have more than one word. Two words or more doesnt work.

So loaded string "Oil and vinegar" isn't equal to the internally set string "Oil in vinegar" according to flash, although it is utf-8 encoded in the database...

blablabla load string "Oil and vinegar" from db into var words

if (words == "Oil and vinegar") { blablabla }
but this condition never evaluates as true....

What am I doing wrong?

[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

Strings
if i have a varible set like this:
textstring = "Hello";
and would like to check the first letter of that variable you would do something like this in C:
if (textstring[0] == H) {}
how do you do this with actionscripting in flash?
What I really want to do is something like this:
somevariable = textstring[x];

Help With Strings
Hello Flashers,
Does anyone know a way to analyze the contents of a string, and if the string contains ONLY spaces, set a boolean like *********=true?

something like:
theString.length=stringLength;
for(count=0; count<stringLength; count++)
{
// the part im not sure how to do goes here
}

~dev

Strings To Int
im loading variables input1, input2, and input3 from a text file and tried to put them into output1 or output2 but for some reason it doesn't work, it displays NaN which is basically stating that it is a full string. however input1 is being filled with 32 or some other numerical value.
input1, input2, and input3 load up ok.however, apparently as strings.
loadVariables("vars.txt","");
//set (output2,input2);
output1 = input1;
output1 = parseInt (output1);

AS And Strings
Hello,

I was wondering...

what can ActionScript allow me to do with string manipulation.
for example:
I want to check if the string is = "".
And
I want to check if the string contains certain characters.

I was hoping i could do this with ActionScript instead of having to pass it back and forth from an outside script.

Thanks for your help.
slobby

Strings Not Getting Set
I have an ASP script which looks at a database and then writes back to Flash MX what the value of the variable is. Here is a tid-bit:

If Not oRs.BOF Then oRs.MoveFirst
oRs.Filter = "PageName='Market2'"
If oRs("PageTitle") <> "null" Then
Response.Write "&marketTwo=" & oRs("PageTitle")
End If

This goes on and on and work really well.
My problem is that Flash MX is not setting the variables correctly.

I declare all variables:

var configuring = "true";
txtLoadStatus = "Configuring site..."
marketOne = "null";
marketTwo = "null";
marketThree = "null";
marketFour = "null";
prodservOne = "null";
prodservTwo = "null";
prodservThree = "null";
prodservFour = "null";

Then request the variables to be changed:

loadVariablesNum("ndtech.asp?command=setup_nav",0, "POST");

Only the variables that have a value other than "null" are written in this ASP page. Those variables, do not change.

Can anyone help??

Thanks,
AP

Help W/ Strings
can someone please explain to me in detail the significant difference between substr() and substring()?
possibly demonstate some good examples of both?
thanks in advance.

Please, No Strings
Hey Guys,
Bellow is a global variable. Im having a hard time because i need the variable value to not be a string so that i can use the data in more ways. Its giving me hard time as it comes out of the XML Doc in a string format.
HELP!
_global.p1ttx = xmlDoc_xml.firstChild.childNodes[3+px].childNodes[1].attributes.x;

Thanks,

ND

Strings
I want to make a function that calculates and displays in mm:ss format the time passed from the beginning of the movie. i found the function-call to get the time passed (getTimer) but i have no idea on formatting. i tried the following, but it did not work. This is supposed to be a part of a preloader.

code: tpass=int(getTimer()/1000);
tmin=(int(tpass/60))
if (tmin.length==1) {tmin="0" + tmin}
tsec=(tpass-(tmin*60));
if (tsec.length==1) {tsec="0" + tsec}
ftime=tmin + ":" + tsec

If you need help this is what it does:
>the first line gets the number of seconds in seconds (not miliseconds)
>the second line gets the number of minutes
>the third line is supposed to add a '0' if the minute is smaller than 10 (i.e. use 09 instead of 9)
>the fourth line gets the number of seconds
>the fifth line is supposed to add a '0' if the second is smaller than 10 (i.e. use 03 instead of 3)


Thank you for the time

XML And Strings
Using Flash MX

How can I perform string functions of xml node data?
Are node data set as read only variables?

If so how then can I make nade data available for manipulation?

Strings
How do I search a string for a certain word or combination?
Example:
input = "Once upon a time"
And I want to search input for "upon", and since upon does exist in the string it will perform the relevant action.
Is this possible?

Strings Maybe?
hey every body... im working with a picture viewer... and like what i want to happen when you click one of the pictures is for it to load the same picture number from a different source...

so what i have now is when you press one of the pics, it traces which pic it is.... for example


Code:
_level0.images.pic15.pic

or

Code:
_level0.images.pic2.pic


now i just need the part where it says pic# so i thought i would try to rid it from every thing else but that part...

here is my feeble attempt


Code:
trace(this.pic.substring(16, myLOC.length-4))


but its not working for some reason... do i have to make this.pic a string before this is done or something?

thank you for any responses...

Fun With Strings
hello everyone, i have a little problem getting a number out of a string...

the var crazy is just fine when its traced... it comes up with things like


Code:
_level0.images.pic32.pic


and i just want the part where it says "32"... so i used this code...


Code:
_root.attempt = crazy.substring(19, crazy.length-4);



but when i tried to trace _root.attempt, it came up as undefined...

Strings Within Strings
howdy y'all
i'm trying to find someway in Flash to search strings within strings. eg - find 'train' in 'bigtrainstation'

does anyone know how to do this?

Strings
Hello, I'm new to flash and I am developing a game for my software engineering class. And i'm having a problem. I want the user to enter a variable and the check to see if the variable is valid or invalid. Can someone please help me!!!!!!!!!!!





Thanks, in advanced

Help W/ Strings
can someone please explain to me in detail the significant difference between substr() and substring()?
possibly demonstate some good examples of both?
thanks in advance.

Strings
Is there a cool aproach to making a string look like it is vibrating?
-Steve

Need A Help With Strings
this code is working fine...


ActionScript Code:
myString = new String();myLV = new LoadVars();myLV.load("isto.txt");myLV.onLoad = function() {    myString = this.var1.toString();    i = myString.length;    play();};stop();


but I would like this to work without loading the TXT file...



is it possible?

Strings
Well new to the forum, but not to flash. I been trying to code up a graphing calculator for a few days. I have got to the point were now iam working with trying to graph logs and other trig functions. SO what i have did was make a few functions that takes an equation the user inputs and turn it into flash code.

ie if the user puts in y=Log(42x²+19x+7) my final string will come out to FinalString:CommonLog(Math.pow(1,2)*42+1*19+7). Now i was wondering if anyone knew how i could evalute that Strings as if it was

var answer:Number=CommonLog(Math.pow(1,2)*42+1*19+7)

Right now if i do var answer:Number=FinalString i get undefined.. anyway if anyone can point me to the right direction it will be greatly appreciated

ps.. hope this makes sense

Need A Help With Strings
this code is working fine...


ActionScript Code:
myString = new String();myLV = new LoadVars();myLV.load("isto.txt");myLV.onLoad = function() {    myString = this.var1.toString();    i = myString.length;    play();};stop();


but I would like this to work without loading the TXT file...



is it possible?

Strings
Hello

Im playin with strings but I dont know how to do something: here goes:

got these 2 strings:

ActionScript Code:
var x:String="andrei learns flash";
var y:String="he finds it very easy";


right so I want to extract "andrei finds flash very easy" from these 2 strings. But I want to do it dynamically. So I do this:


ActionScript Code:
var z:String=x.substring(0, x.indexOf(" ")) + y.substr(y.indexOf(" "),6) + x.substr(x.lastIndexOf(" "),6) + " " + y.substr(y.indexOf("v"),10);
 
trace(z);


But what i wrote here is not quite what I call "dynamically" because I need to see the strings, in order to use the above code. What if I didnt know before what the stirngs are and I want to extract a word from the 1st string, + second word from the second string, and so on? I cannot use the substring method if I want to do everything dynamically, because substring needs the exact position of the letters (which I find useless if for example I need to concatenate user's input text ).
SO all I want is to modify the above code as to not count the letters, because this is not dynamically... I need to assume that I dont already know the strings.

Im not the best at explaining things but I hope you understand what I need

Oh btw guys HAPPY NEW YEAR

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.

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();

[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...

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