Hi everyone. Been lurking for a while…Excellently wonderful resource
Now, I am making a Slideshow. And the great news is - i’ve got it to work! (-: The bad news is, every time it transitions between images, it takes up a hell of a lot of CPU. Like, 50% CPU usage while it’s transitioning! Now that’s insane! I need your help. Interested in helping? Hope so…
So my primary question is: what is causing this swf to be a CPU hog & how do I fix it?, and secondary question is: is there a better way of doing this? Let me step out what I am doing in my file:
A)load an XML file and Extract it’s content into an array ‘image[]’
B)Call function bix();, which attachMovie’s MC’s with a higher depth each time.
C)Call w00t(); which houses my MovieClipLoader. Each time I call w00t, MovieClipLoader loads the current xml image file (from the array) and loadClip’s it into the recently attachMovie’d MC (see (B))
D) Once the MC has loaded (OnLoadComplete), I do two things:
(i) Tell the mask Sitting inside the attachedMovie to play. THe mask is a MC which makes a fancy transition. Because attachMovie increments on a higher depth each time, it creates the effect of the new image transitioning OVER the previous image - better than a simple fade or straight swap.
(ii)Call Slideshow(); which is a setInterval pause function. At the end of the interval, I clear the Interval and then increment “s” (what makes the attachMovie MC’s name unique) and “p” (what keeps track of which image in the array we are up to). I also have set up an if statement to remove the last attachMovie MC, otherwise the whole swf becomes sluggish really fast because of the ever growing number of MC’s called with attachMovie.
Slideshow’s final task is to look back to bix();, which sets off the process all over again, and keeps going through until we have gotten to the last image, and then starts over seemlessly.
var p:Number = 0;
s = 1;
delay = 5000;
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
bix();
//thumbnails_fn();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("slideshow.xml");
bix = function() {
this.attachMovie("picMask","img"+s,s);
w00t();
}
w00t = function() {
/*********************************************************************/
//init
var myMCL = new MovieClipLoader();
/*********************************************************************/
//callbacks
myMCL.onLoadStart = function (targetMC)
{
var loadProgress = myMCL.getProgress(targetMC);
trace(s);
}
myMCL.onLoadProgress = function (targetMC, loadedBytes, totalBytes) {
}
myMCL.onLoadComplete = function (targetMC)
{
}
myMCL.onLoadInit = function (targetMC)
{
_root["img"+s].wicked.play();
slideshow();
}
myMCL.onLoadError = function (targetMC, errorCode)
{
}
/********************************************************************/
//load the files in to their respective targets
myMCL.loadClip(image[p],_root["img"+s].picture);
}
function slideshow() {
myInterval = setInterval(pause_slideshow, delay);
function pause_slideshow() {
clearInterval(myInterval);
if(p < 2){
if(s >= 2) {
q = s - 1;
_root["img"+q].removeMovieClip();
trace("meh");
}
p++;
s++;
bix();
} else {
q = s - 1;
_root["img"+q].removeMovieClip();
p = 0;
s++;
bix();
}
}
}