PDA

View Full Version : XML - Select data based on URL string



riot
September 15th, 2008, 11:29 PM
My english not is sooo good (but I bet a caipirinha that it's better than your portuguese) =D

So... a simple AS:


function loadXML(loaded) {
titulo = menuXML.childNodes[X].attributes.titulo;
titulo_sub = menuXML.childNodes[X].childNodes[Y].attributes.titulo;
titulo_txt.htmlText = titulo +" # "+ titulo_sub;
};
var menuXML:XML = new XML();
menuXML.ignoreWhite = true;
menuXML.load("_xml/menu.xml");
menuXML.onLoad = function(ok) {
if (ok) {
loadXML();
}
};

What I'm trying to do: get the values for X and Y from the URL string (e.g.: ?x=0&y=2). I tried several times here but unsucessfully.

Thanks in advance.

[]'s
Eduardo

Wilhelm Murdoch
September 16th, 2008, 12:10 AM
This tutorial should help you out. (http://www.netlobo.com/url_query_string_javascript.html) :)

riot
September 16th, 2008, 12:21 AM
Wilhelm, thanks for the attention.

So... I don't have problems getting the values from the string, only assigning the values for the 2nd and 3rd lines of my actionscript.

riot
September 16th, 2008, 12:33 AM
My XML: 47964

So... I have a menu populated with this XML. Every button gives me a different URL string based on the nodes ITEM and SUBITEM. For example: the subitem "Como participar" will give me on the URL something like "index.php?i=1&k=4".

So... how to assing the values from i to X and k to Y on my actionscript?

What I'm doing? a dynamic title bar (with the same XML used on my menu).

eirche
September 16th, 2008, 01:02 AM
to pass variable to a flash application, do something like this



<object >
<param name="movie" value="flashapp.swf?x=2&y=7" />
<embed src="flashapp.swf?x=2&y=7" />
</object>

riot
September 16th, 2008, 01:26 AM
I know that my language limitations doesn't help. I'll try to be more simple:

On my AS I have this:

titulo = menuXML.childNodes[X].attributes.titulo;
titulo_sub = menuXML.childNodes[X].childNodes[Y].attributes.titulo;

And on my URL I have this:

www.my_url_is_cool_and_fake.com/index.php?i=0&k=0

So... what I'm trying it's on the AS to assign the value from i to X and from k to Y dinamically once every time I click on a button the values of i and k are changing.