Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML getURL

Status
Not open for further replies.

FlashN00b

IS-IT--Management
Jul 7, 2008
4
0
0
US
I have done a search on XML getURL, but I still cannot get my code to work.

"XML document"
--------------------
<Links>
<linkNode linkURL=" <linkNode linkURL=" <linkNode linkURL=" <linkNode linkURL="</Links>
---------------------

"ActionScript"
---------------------
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

links_xml = new XML();
links_xml.onLoad - startsSlideShow;
links_xml.load("links.xml");
links_xml.ignoreWhite = true;

function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;

rtLnkNode = links_xml.firstChild;
firstLinkNode = rtLnkNode.firstChild;
currentLinkNode - firstLinkNode;
updateSlide(firstSlideNode);
setInterval(timer,10000);
}
}

function timer() {
nextSlideNode = currentSlideNode.nextSibling;
nextLinkNode = currentLinkNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
currentLinkNode = firstLinkNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
currentLinkNode = nextLinkNode;
updateSlide(nextSlideNode);
}
}


function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}

next_btn.onRelease = function() {
nextSlideNode = currentSlideNode.nextSibling;
nextLinkNode = currentLinkNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
currentLinkNode = firstLinkNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
currentLinkNode = nextLinkNode;
updateSlide(nextSlideNode);
}
};

link_btn.onRelease = function() {
getURL(currentLinkNode.attributes.linkURL);
};

-------------
 
This is the first time I am working with XML and Flash combination.

Update XML
-----------------------
<Slides>
<slideNode linkURL=" jpegURL="images/ad1.jpg">Ad 1</slideNode>
<slideNode linkURL=" jpegURL="images/ad2.jpg">Ad 2</slideNode>
<slideNode linkURL=" jpegURL="images/ad3.jpg">Ad 3</slideNode>
<slideNode linkURL=" jpegURL="images/ad4.jpg">Ad 4</slideNode>
</Slides>
-----------------------

ActionScript
-----------------------
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
setInterval(timer,10000);
}
}

function timer() {
nextSlideNode = currentSlideNode.nextSibling;
nextLinkNode = currentLinkNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
updateSlide(nextSlideNode);
}
}

function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}

next_btn.onRelease = function() {
nextSlideNode = currentSlideNode.nextSibling;
nextLinkNode = currentLinkNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
updateSlide(nextSlideNode);
}
};

link_btn.onRelease = function() {
getURL(current.SlideNode.attributes.linkURL);
};
 
Let's start from the beginning step by step:
Code:
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

function startSlideShow(success) {
	if (success == true) {
		rootNode = slides_xml.firstChild;
		totalSlides = rootNode.childNodes.length;
		firstSlideNode = rootNode.firstChild;
		currentSlideNode = firstSlideNode;
		currentIndex = 1;
		updateSlide(firstSlideNode);
		// setInterval(timer,10000);
	}
}

function updateSlide(newSlideNode) {
	imagePath = newSlideNode.attributes.jpegURL;
	slideText = newSlideNode.firstChild.nodeValue;
	loadMovie(imagePath, targetClip);
}
This is the first segment of your code. All fine as ActionScript 1, except "targetClip" is not defined - do you have it defined elsewhere?

Kenneth Kawamoto
 
targetClip is defined (as a movie clip), where the images are going to loaded. That works fine.

I put the linkURL to output into slideText, to see if it was reading the XML file correctly. It did output correctly.

When I click on the link_btn, nothing shows on the web browser/

ActionScript Code update:
------------------------------------------
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("slides.xml");
slides_xml.ignoreWhite = true;

function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
setInterval(timer,10000);
}
}

function timer() {
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
updateSlide(nextSlideNode);
}
}

function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
}

next_btn.onRelease = function() {
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
currentIndex = 1;
currentSlideNode = firstSlideNode;
updateSlide(firstSlideNode);
} else {
currentIndex++;
currentSlideNode = nextSlideNode;
updateSlide(nextSlideNode);
}
};

link_btn.onRelease = function() {
getURL(currentSlideNode.attributes.linkURL);
};
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top