Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

marvi

busca no flash

Recommended Posts

Ola pessoal,

 

tenho um busca em flash ligado com xml e eu estou com busca funcionando bem e tranquilo...ele tem um campo e é digitado na boa... o usuario teria que definir primeiramente por um dos criterios de busca: se por Titulo, Autor, Palavra-Chave, até aí o meu único campo do busca consegue pegar isso tudo, mas a questão é a Area ou Sub-Area. No caso de busca por Area e Sub-Area a diferença seria que o usuario nao digitaria, e sim escolheria entre as opções disponiveis num menu suspenso. Se preciso mando o fla por e-mail junto com xml...como fazer esse menu suspenso no flash que reconheça o banco xml?

 

Meu campo de digitação reconhece o banco e mostra os dados do xml, mas como fazer tipo um menu suspenso para mostrar os resultados da área ou sub área com meu xml, é quase igual o campo de digitação que ja esta ok?

 

Preciso muito e Obrigado!

 

Ha, abaixo vai o codigo:

 

XML:

 

<database>	<record title="Flash 5" description="Create animated, vector-based Web content.">	<link>http://www.uol.com.br</link>	<keywords>Macromedia|Flash|SWF|XML|Shockwave|ActionScript|ActionScripting</keywords>	</record>	<record title="Ultrashock" description="The ultimate knowledge base for multimedia developers.">	<link>http://www.uol.com.br</link>	<keywords>Ultrashock|Ultra Shock|Sources|Tutorials|Macromedia|Flash|SWF|Shockwave|ActionScript|ActionScripting</keywords>	</record>	<record title="Ack!" description="ActionScript Component Kit">	<link>http://chattyfig.figleaf.com/ack</link>	<keywords>ActionScript|Action Script|ActionScripting|XML|Components|Extensions|Widgets</keywords>	</record>	<record title="Flashcoders" description="High traffic mailing list for programmers using Macromedia Flash 5. This list is run by Branden Hall of Fig Leaf Software.">	<link>http://chattyfig.figleaf.com/a</link>	<keywords>Flash|ActionScript|Action Script|ActionScripting|XML</keywords>	</record>	<record title="ActionScript: The Definitive Guide" description="For web developers and web authors who want to go beyond simple Flash animations to create enhanced Flash-driven sites. Regardless of your level of programming expertise, this combination of ActionScript fundamentals, applications, and handy quick-reference will have you scripting like a pro.">	<link>http://www.oreilly.com/catalog/actscript/</link>	<keywords>Book|Books|Flash|ActionScript|Action Script|ActionScripting|XML</keywords>	</record>	<record title="Dreamweaver 4" description="Make short work of Web site and HTML page production.">	<link>http://www.macromedia.com/software/dreamweaver</link>	<keywords>Macromedia|Dreamweaver|Flash|HTML|JavaScript|CSS|Editor|Webdesign</keywords>	</record>	<record title="Freehand 10" description="Create vector-based illustrations for Flash and for print.">	<link>http://www.macromedia.com/software/freehand</link>	<keywords>Macromedia|Freehand|Flash|Illustration|Illustrator|DTP|Print|Design</keywords>	</record></database>

action script:

 

 

stop(); fscommand("allowscale", "false");var dbArray = new Array();var dbXML = new XML();// handle xmldbXML.onLoad = function()   {	// variable init	var title, description, link, keywords;	var ndRoot = this.firstChild;		// loop throug the entire xml tree	for(var i = 0; i < ndRoot.childNodes.length; i++)	   {		// ignore white spaces		if(ndRoot.childNodes[i].nodeName != null)		   {			// get node attributes values			title = ndRoot.childNodes[i].attributes.title;			description = ndRoot.childNodes[i].attributes.description;			// loop throug the specific node 			for(var j = 0; j < ndRoot.childNodes[i].childNodes.length; j++)			   {				if(ndRoot.childNodes[i].childNodes[j].nodeName == "link")				   {					// get node value					link = ndRoot.childNodes[i].childNodes[j].firstChild.nodeValue;				}				else if(ndRoot.childNodes[i].childNodes[j].nodeName == "keywords")				   {					// get the keywords					keywords = ndRoot.childNodes[i].childNodes[j].firstChild.nodeValue.split("|");				}			}			dbArray.push(new _root.record(title, description, keywords, link));			// create a new instance of the -=record=- class with these informations		}	}}// record class constructorfunction record(title, description, keywords, link)   {	this.title = title	this.description = description;	this.keywords = keywords;	this.link = link;}// search functionfunction search(string)   {	// variable init	var nResults = 0;		for(var i = 0; i < dbArray.length; i++)	   {		// loop throug the keywords Array		for(j = 0; j < dbArray[i].keywords.length; j++)		   {			// check if the string matches with a keyword			if (dbArray[i].keywords[j].toLowerCase() == string)			   {				found = true; nResults++;				break;			}		}		if(found)		   {			// show the results...			results += "<b><a href=\""+ dbArray[i].link + "\"><u>" + dbArray[i].title + "</u></a></b>" + "<br>";			results += dbArray[i].description + "<br><br>";			found = false;		}	}	if(nResults == 0)	   {		// if no results...		results = "<b>No links found. Try again...</b>";	}	gotoAndStop(10);}// loed the xml filedbXML.load("database.xml");Selection.setFocus("word");

 

Obrigado!

Marcelo

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.