Hi Everyone,
I am a designer and am really trying to learn XML calls into flash, and actionscript in general. I have spent a while trying to figure this out and some of your expertise would be greatly appreciated!
If I can even get pointed in the right direction it would really help!
The goal is to modify an XML search that I found in a tutorial on Kirupa, I need to replace the section that opens a browser with an asfunction:myBook.flipGotoPage parameter…
Here is the link to the Kirupa XML example I’m working with:
[ http://www.kirupa.com/web/xml/examples/searchbestof.htm ]
Below is the part of the code that pops a new browser window from the url field of the XML document:
DisplayNodes = function(nodes, field_txt){
field_txt.htmlText = "";
var entry;
var separator = "<br>_______________________<br><br>";
for (var i=0; i<nodes.length; i++){
entry = "";
entry += "<b>"+ nodes*.childNodes[0].firstChild.nodeValue +"</b>";
entry += " by: "+ nodes*.childNodes[1].firstChild.nodeValue;
entry += "<br>"+ nodes*.childNodes[2].firstChild.nodeValue;
if (nodes*.attributes.url.length){
entry += "<br><a href='" + nodes*.attributes.url;
entry += "'><font color='#0000FF'>Read more...</font></a>";
My goal is to make the search result use asfunction and work just like the below code did in my first attempt at creating a search [my first non xml search attempt]
var keyword = new Array();
_root.search.onRelease = function(){
_root.linkText = "";
for(j = 0; j < textArr.length; j++){
_level0["count"+j] = 0;
var p:Number = j+1;
keyword = textArr[j].split(" ");
for(i = 0; i < keyword.length; i++){
if(keyword*.charAt(keyword*.length-1) == ","){
l = keyword*.lastIndexOf(",")-1;
wordmatch = keyword*.substring(0,(l+1));
}else if(keyword*.charAt(keyword*.length-1) == "."){
l = keyword*.lastIndexOf(".")-1;
wordmatch = keyword*.substring(0,(l+1));
}else if(keyword*.charAt(keyword*.length-1) == "?"){
l = keyword*.lastIndexOf("?")-1;
wordmatch = keyword*.substring(0,(l+1));
}else{
wordmatch = keyword*;
}
if(_root.searchTxt.toLowerCase() == wordmatch.toLowerCase()){
_level0["count"+j]+=1;
if(_level0["count"+j] <= 1){
_root.linkText += ("<a href=\"asfunction:myBook.flipGotoPage,"+p+"\">page "+p+" contains the word <font color=\"#FF0000\"><B><I>"+wordmatch+"</I></B></font></a><br />");
}
}
}
}
}
Specifically, this is the section that I am trying make work in the XML based search…
_root.linkText += ("<a href=\"asfunction:myBook.flipGotoPage,"+p+"\">page "+p+" contains the word <font color=\"#FF0000\"><B><I>"+wordmatch+"</I></B></font></a><br />");
I realize that they are TOTALLY different ways of performing the search… and that I may be in way over my head, however I found this site was really designer friendly so I thought this post might help me get in the right direction.
Can anyone help with this?
Cheers,
J