Hello everyone,
Can anyone show me how to create an autoplay- slideshow capability to this XML portfolio? I would like for it to automatically play each image. I've tried several ways but it hasn't worked. Any help would be greatly appreciated! Thanks in advance.. I copied my codes below
FLASH CODE:
var myXML:XML = new XML();
myXML.ignoreWhite = true;
myXML.load("wedc.xml");
var Name:Array = Array();
var description:Array = Array();
var thumbPath:Array = Array();
var picPath:Array = Array();
var linkURL:Array = Array();
var bgcolor:Array = Array();
_root.numberPerRow = 3;
_root.gapH = 5;
// horizontal space
_root.gapV = 5;
// vertical space (between rows)
_root.rowPerPage = 5;
// how many rows per page
_root.itemsPerPage = _root.numberPerRow*_root.rowPerPage;
_root.currentPage = 1;
myXML.onLoad = function(success) {
displayPage();
};
function displayPage() {
//remove existing thumbnails
for (var i = 0; i<_root.numberOfSites; i++) {
removeMovieClip(flash_mc["img"+i]);
}
xml = myXML.firstChild;
_root.numberOfSites = xml.childNodes.length;
var numberOfPages:Number = Math.ceil(_root.numberOfSites/_root.itemsPerPage);
// display page: what/what
mc_pagination.pageof.text = "Page: "+_root.currentPage+"/"+numberOfPages;
for (var i = 0; i<numberOfPages; i++) {
mc_pagination.mc_paging.duplicateMovieClip("mc_paging"+i, i);
mc_pagination["mc_paging"+i].pageNumber._width = 15;
mc_pagination["mc_paging"+i].mc_helper._width = 15;
mc_pagination.mc_paging._width = 11;
mc_pagination["mc_paging"+i].pageNumber.text = i+1;
// if there is only one page, don't display the pagination buttons
if (numberOfPages == 1) {
mc_pagination["mc_paging"+i]._visible = false;
}
// disable the current page number button and change its color
if (mc_pagination["mc_paging"+i].pageNumber.text == _root.currentPage) {
myColor1 = new Color(this.mc_pagination["mc_paging"+i]);
myColor1.setRGB(0x37281f);
mc_pagination["mc_paging"+i].enabled = false;
} else {
mc_pagination["mc_paging"+i].enabled = true;
}
mc_pagination["mc_paging"+i]._x = 700-(mc_pagination.mc_paging._width+2)*(numberOfPages-i);
//trace(mc_pagination["mc_paging"+i]._x);
}
var firstItemThisPage:Number = _root.itemsPerPage*(_root.currentPage-1);
var LastItemThisPage:Number = firstItemThisPage+_root.itemsPerPage;
LastItemThisPage>_root.numberOfSites ? LastItemThisPage=_root.numberOfSites : LastItemThisPage=LastItemThisPage;
for (var i = firstItemThisPage; i<LastItemThisPage; i++) {
Name[i] = xml.childNodes[i].childNodes[0].childNodes[0].nodeValue;
description[i] = xml.childNodes[i].childNodes[1].childNodes[0].nodeValue;
thumbPath[i] = xml.childNodes[i].childNodes[2].childNodes[0].nodeValue;
picPath[i] = xml.childNodes[i].childNodes[3].childNodes[0].nodeValue;
linkURL[i] = xml.childNodes[i].childNodes[4].childNodes[0].nodeValue;
bgcolor[i] = xml.childNodes[i].childNodes[5].childNodes[0].nodeValue;
flash_mc.img.duplicateMovieClip("img"+i, i);
//_root["movie"+i]._x = movie0._x+(i*180);
realRow = Math.floor(i/_root.numberPerRow);
row = realRow-((_root.currentPage-1)*_root.rowPerPage);
flash_mc["img"+i]._x = flash_mc.img._x+(i-(realRow*_root.numberPerRow))*(flash_mc.img._width+_root.gapH);
flash_mc["img"+i]._y = flash_mc.img._y+row*(flash_mc.img._height+_root.gapV);
flash_mc["img"+i].img_mc.loadMovie(thumbPath[i]);
flash_mc["img"+i].theSiteName = Name[i];
flash_mc["img"+i].theLinkURL = linkURL[i];
flash_mc["img"+i].thePicPath = picPath[i];
flash_mc["img"+i].theBgColor = bgcolor[i];
flash_mc["img"+i].theSiteDesc = description[i];
//load the first big image
getFirst(picPath[firstItemThisPage], linkURL[firstItemThisPage], bgcolor[firstItemThisPage], Name[firstItemThisPage], description[firstItemThisPage]);
}
}
//for loading first big image
function getFirst(thePicPath:String, theLinkURL:String, theBgColor:String, theSiteName:String, theSiteDesc:String) {
theBigImageContainer = _root.main.big_mc.big_mc_image;
theBigImageContainer.loadMovie(thePicPath);
if (theSiteDesc == undefined) {
_root.main.textbox.siteName.text = theSiteName;
} else {
_root.main.textbox.siteName.text = theSiteName+" - "+theSiteDesc;
}
percentage = 0;
var colorful = new Color("_root.main.mc_bgcolor");
var theColor = "0x"+theBgColor;
colorful.setRGB(theColor);
flash_mc.a_mc.onEnterFrame = function() {
percentage = theBigImageContainer.getBytesLoaded()/theBigImageContainer.getBytesTotal()*100;
theBigImageContainer._visible = false;
_root.main.big_mc.loader.gotoAndStop(Math.round(percentage));
if (percentage>99) {
delete flash_mc.a_mc.onEnterFrame;
theBigImageContainer._visible = true;
_root.main.big_mc.loader._visible = false;
_root.main.big_mc.changeColor();
}
};
_root.main.big_mc.onRelease = function() {
getURL(theLinkURL, "_blank");
};
if (theLinkURL == undefined) {
_root.main.big_mc.enabled = false;
} else {
_root.main.big_mc.enabled = true;
}
}
XML CODE:
<?xml version="1.0" encoding="iso-8859-1"?>
<wedb>
<site>
<name></name>
<description></description>
<thumbnail>./images/tn_wedb08_021.jpg</thumbnail>
<pic>./images/wedb08_021.jpg</pic>
<url></url>
<bgcolor>67a5b2</bgcolor>
</site>
etc..
XML- adding slideshow capability
Started by StudioAndy, Feb 04 2008 11:17 AM
No replies to this topic
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users
