• Home
  • Free Tutorials
  • Free Video Tutorials

Adobe Photoshop
Autodesk 3ds Max
CSS
Flash
Help Center Live
iPhone
Joomla
Make Money Online!
Mambo
mIRC
Outlook Express
SEO / SEM
Simple Machine Forum
Target Explorer

XML Image Slideshow with Preloader

Category : Flash Views : 45835
Version : 8 Rating : 
3.3/5 (51 votes)
  • Currently 3.29/5
  • 1
  • 2
  • 3
  • 4
  • 5
Type : Text Source File: xml-image-slideshow-with-preloader.zip
Result: See the result


Previous | 1 | 2 | 3 | Next

Go back to the flash, open the actions for the first frame and paste this:
//new XML object to load our xml file var img_xml = new XML() //ignore white to prevent problems img_xml.ignoreWhite = true; //load the xml img_xml.load("images.xml"); //new array to store the path to the images var imgArray = new Array(); //when the xml load this is called img_xml.onLoad = function() { //get the timer from the first node of the xml file var slideTimer:Number=Number(img_xml.firstChild.firstChild.attributes.time); //loop for the number of nodes inside the xml for (i = 1; i < img_xml.firstChild.childNodes.length; i++) { //populate the imgArray with the images _root.imgArray[i - 1] = img_xml.firstChild.childNodes[i].attributes.path; } //loads the first image inside the loader component imgLoader.load( _root.imgArray[0] ); //"setInterval" to call the function "nextImage" every 2 //secs if slideTimer is equal to 2000 milliseconds setInterval(nextImage, slideTimer); } //the current image is 0, the first. var curImage = 0; _root.onEnterFrame = function() { //if the image isn't 100% loaded if (imgLoader.percentLoaded != 100) { //Bar is visible Bar._visible = true //and scale it by the percentage loaded Bar._xscale = imgLoader.percentLoaded } else { //if the image is completely loaded //the Bar needs to be invisible. Bar._visible = false } } //called by "setInterval" function nextImage() { //increases current image by 1. _root.curImage++ //if curImage is the last image then //go back to the first one if (_root.curImage == _root.imgArray.length) { //first image _root.curImage = 0; } //loads the new image using the path in the imgArray. _root.imgLoader.load( _root.imgArray[curImage]); }

Done, test your code. To see the progress bar working use the "Simulate Download" option on the flash debugger.


del.icio.us digg it Reddit Stumble Upon Technorati

Previous | 1 | 2 | 3 | Next
How to Video Tutorials on software by Helpvids.com

Video tutorial: Forex trading



Sponsors



Advertisement









Studio | Advertisement | About Webzo | Contact Webzo | Terms of Use | Free Video Tutorials by Helpivds

Copyright © 2007 NR Concepts Ltd. All rights reserved.