Hola a todos...
Mi primer post aquí, así que por favor, sea amable!
Ive sido la construcción de un mapa en flash que obtiene la mayor parte de su información desde un archivo XML. Todo parece funcionar bien con la excepción de las URL de enlaces a otras páginas de nuestro sitio.
La idea es usuario hace clic en una ciudad en el mapa, información sobre la ciudad que aparece en un cuadro de información común en el SWF - Esta información incluye enlaces a la página de las ciudades. Todo pasa por el XML en el archivo SWF correctamente, con la excepción de los enlaces / URL.
Heres una muestra de mi código XML, que está siendo cargado en mi swf. (URL fueron despojados por el software del foro, pero es obvio que van):
<?xml version="1.0" encoding="utf-8"?>
<site>
<pages>
<page page_number="1">
<town>NEW LONDON</town>
<title>New London Headline Goes Here</title>
<date>Date Goes Here ...</date>
<content>Short abstract of town here ...</content>
<link><a href='URL GOES HERE'>VISIT TOWN PAGE</a></link>
<image>zip06logo.png</image>
</page>
<page page_number="2">
<town>NORTH STONINGTON</town>
<title>North Stonington Headline Goes Here</title>
<date>Date Goes Here ...</date>
<content>Short abstract of town here ...</content>
<link><a href='URL GOES HERE'>VISIT TOWN PAGE</a></link>
<image>zip06logo.png</image>
</page>
</pages>
</site>
- <?xml version="1.0" encoding="utf-8"?>
-
- <site>
- <pages>
-
- <page page_number="1">
- <town>NEW LONDON</town>
- <title>New London Headline Goes Here</title>
- <date>Date Goes Here ...</date>
- <content>Short abstract of town here ...</content>
- <link><a href='URL GOES HERE'>VISIT TOWN PAGE</a></link>
- <image>zip06logo.png</image>
- </page>
-
- <page page_number="2">
- <town>NORTH STONINGTON</town>
- <title>North Stonington Headline Goes Here</title>
- <date>Date Goes Here ...</date>
- <content>Short abstract of town here ...</content>
- <link><a href='URL GOES HERE'>VISIT TOWN PAGE</a></link>
- <image>zip06logo.png</image>
- </page>
- </pages>
-
- </site>
Heres y el (tijeras) con el código del documento de Flash.:
//Create a holder that will contain the title, content and image.
var holder:MovieClip = new MovieClip();
holder.addChild(townText);
holder.addChild(titleText);
holder.addChild(dateText);
holder.addChild(contentText);
holder.addChild(linkText);
//Add the holder to the stage
addChild(holder);
//Hide the holder at the beginning of the movie.
//We don't want to show any content before the title, content and image has
//been loaded.
holder.visible = false;
// BUTTON CODE HERE
// END BUTTON CODE
//Specify the path to the XML file.
//You can use my path or your own.
var xmlFilePath:String = "test.xml";
// LOAD XML
//We save the loaded XML data into a variable
var XMLData:XML;
//Load the XML file.
//We call the xmlDataLoaded() function when the loading is complete.
var loader = new URLLoader();
loader.load(new URLRequest(xmlFilePath));
loader.addEventListener(Event.COMPLETE, xmlDataLoaded);
//This function is called when the XML file is loaded
function xmlDataLoaded(e:Event):void {
//Create a new XML object from the loaded XML data
XMLData = new XML(loader.data);
XMLData.ignoreWhitespace = true;
//Call the function that adds event listeners for the buttons
addEventListeners();
// EVENT LISTENERS FOR BUTTONS ALL 38 OF 'EM - CODE SNIPPED
//Loop through the pages found in the XML file
for each (var page:XML in XMLData.pages.page) {
//Check if the page number that we're looking is found from the XML data.
//The "page.@page_number" refers to the page's "page_number" attribute in the XML file.
if (page. @ page_number == pageNumber) {
//Set the title from the XML
titleText.text = page.title;
//Set the town from the XML
townText.text = page.town;
//Set the title from the XML
dateText.text = page.date;
linkText.htmlText = page.link;
contentText.text = page.content;
//Load the image (the image path is specified in the XML)
var imageLoader = new Loader();
imageLoader.load(new URLRequest(page.image));
//Listen when the image is loaded
imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
//We can exit the loop now
break;
}
}
}
- //Create a holder that will contain the title, content and image.
- var holder:MovieClip = new MovieClip();
- holder.addChild(townText);
- holder.addChild(titleText);
- holder.addChild(dateText);
- holder.addChild(contentText);
- holder.addChild(linkText);
-
- //Add the holder to the stage
- addChild(holder);
-
- //Hide the holder at the beginning of the movie.
- //We don't want to show any content before the title, content and image has
- //been loaded.
- holder.visible = false;
-
- // BUTTON CODE HERE
-
- // END BUTTON CODE
-
- //Specify the path to the XML file.
- //You can use my path or your own.
- var xmlFilePath:String = "test.xml";
-
- // LOAD XML
-
- //We save the loaded XML data into a variable
- var XMLData:XML;
-
- //Load the XML file.
- //We call the xmlDataLoaded() function when the loading is complete.
- var loader = new URLLoader();
- loader.load(new URLRequest(xmlFilePath));
- loader.addEventListener(Event.COMPLETE, xmlDataLoaded);
-
- //This function is called when the XML file is loaded
- function xmlDataLoaded(e:Event):void {
-
- //Create a new XML object from the loaded XML data
- XMLData = new XML(loader.data);
- XMLData.ignoreWhitespace = true;
-
- //Call the function that adds event listeners for the buttons
- addEventListeners();
-
- // EVENT LISTENERS FOR BUTTONS ALL 38 OF 'EM - CODE SNIPPED
-
- //Loop through the pages found in the XML file
- for each (var page:XML in XMLData.pages.page) {
-
- //Check if the page number that we're looking is found from the XML data.
- //The "page.@page_number" refers to the page's "page_number" attribute in the XML file.
- if (page. @ page_number == pageNumber) {
-
- //Set the title from the XML
- titleText.text = page.title;
-
- //Set the town from the XML
- townText.text = page.town;
-
- //Set the title from the XML
- dateText.text = page.date;
- linkText.htmlText = page.link;
- contentText.text = page.content;
-
-
- //Load the image (the image path is specified in the XML)
- var imageLoader = new Loader();
- imageLoader.load(new URLRequest(page.image));
-
- //Listen when the image is loaded
- imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
-
- //We can exit the loop now
- break;
- }
- }
- }
Pensé que se declara:
linkText.htmlText = page.link;
...sería suficiente, pero appare notly no. La URL se muestra, pero no es un enlace. (Ive también estableció el cuadro de texto dinámico para linkText a HTML).
Cant averiguar qué Im que hace mal aquí....
Gracias por la ayuda que puede dar.
= X