-
Okay, so I've been reading through all of this and I've attempted to alter a slideshow I'm working on to use setInterval. I use Flash MX btw.
I am creating a slideshow where I use two buttons to navigate between the images. The images load via xml and load into a movieclip called myImage then a movieclip called mc_fader plays over top of the image to reveal the image. mc_fader automatically resizes based on the width of the movie. I want have the "next" button set up so that when a user clicks on it, he or she sees a preloader in a text box called progress_txt that shows how much of the next image has loaded. When that image has loaded, I would like to show the image(myImage) with mc_fader overtop and cause mc_fader to play. But when I click on the "next" button, the progress_txt remains "Loading Complete". If I click the "next" button twice very quickly, it works. What gives?
to see an example click here
Code:
slides_xml = new XML();
slides_xml.onLoad = startSlideShow;
slides_xml.load("fashion_slideshow.xml");
slides_xml.ignoreWhite = true;
//
// Show the first slide and intialize variables
function startSlideShow(success) {
if (success == true) {
rootNode = slides_xml.firstChild;
totalSlides = rootNode.childNodes.length;
firstSlideNode = rootNode.firstChild;
currentSlideNode = firstSlideNode;
currentIndex = 1;
updateSlide(firstSlideNode);
}else gotoAndStop(10);
}
//
// Updates the current slide with new image and text
function updateSlide(newSlideNode) {
fader = mc_fader;
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, myImage);
}
checkImageLoadingStatus = function(){
progress_txt.text = "boogabooga";
// var total = 0 ;
var total = myImage.getBytesTotal();
if (isNaN(total) || total == 0){
progress_txt.text = "Loading...";
}else {
var loaded = myImage.getBytesLoaded();
if (total == loaded){
progress_txt.text = "Loading Complete";
mc_fader._width = myImage._width;
mc_fader.gotoAndPlay(1);
// mc_fader._visible = true;
clearInterval(loadingID);
}else{
progress_txt.text = Math.round(loaded/1024) +" kb of "+ Math.round(total/1024); // divide 1024 to get kilobytes
}
}
}
//
// Event handler for 'Next slide' button
next_btn.onRelease = function() {
progress_txt.text = "";
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
break;
mc_endfade.gotoAndPlay(2);
} else {
clearInterval(loadingID); // clear any current interval that might be running
loadingID = setInterval(checkImageLoadingStatus, 50); // every 50 milliseconds
mc_endfade.gotoAndStop(1);
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
checkImageLoadingStatus();
}
};
//
// Event handler for 'Previous slide' button
back_btn.onRelease = function() {
// removeMovieClip.myImage;
// this._parent.createEmptyMovieClip("myImage",1);
// myImage._x = 87.5;
// myImage._y = 0;
previousSlideNode = currentSlideNode.previousSibling;
if (previousSlideNode == null) {
break;
mc_endfade.gotoAndPlay(2);
} else {
clearInterval(loadingID); // clear any current interval that might be running
loadingID = setInterval(checkImageLoadingStatus, 50); // every 50 milliseconds
checkImageLoadingStatus();
mc_endfade.gotoAndStop(1);
currentIndex--;
updateSlide(previousSlideNode);
currentSlideNode = previousSlideNode;
}
};
-
Total Universe Mod
looks like its working to me, you just have to wait a sec before the image actually pops up.
It seems the reason your seeing "Loading Complete" is because you are displaying it anytime total == loaded. Since you initialize loaded as 0, the first time you check total it will return that 0 bytes are loaded thus making your check true right off the bat. try changing this line
var loaded = myImage.getBytesLoaded();
into this line
var loaded = myImage.getBytesTotal(); //changed getBytesLoaded to getBytesTotal
-
Thanks for the help jAQUAN. Pretty simple fix, butI had to add a bit more in to get it to work. here's the final code that worked (in case anyone is interested).
Actionscript:
Code:
checkImageLoadingStatus = function(){
var total = myImage.getBytesTotal();
if (isNaN(total) || total == 0){
progress_txt.text = "Loading...";
}else {
bytesLoaded = _root.myImage.getBytesLoaded();
bytesTotal = _root.myImage.getBytesTotal();
var loaded = myImage.getBytesTotal();
percent = bytesLoaded/bytesTotal;
if (percent == loaded){
progress_txt.text = "Loading Complete";
mc_fader._width = myImage._width;
mc_fader.gotoAndPlay(1);
// mc_fader._visible = true;
clearInterval(loadingID);
}else{
progress_txt.text = Math.round(loaded/1024) +" kb of "+ Math.round(total/1024); // divide 1024 to get kilobytes
}
}
};
// Event handler for 'Next slide' button
next_btn.onPress = function() {
progress_txt.text = "";
nextSlideNode = currentSlideNode.nextSibling;
if (nextSlideNode == null) {
break;
mc_endfade.gotoAndPlay(2);
} else {
// clearInterval(loadingID); // clear any current interval that might be running
loadingID = setInterval(checkImageLoadingStatus, 50); // every 50 milliseconds
mc_endfade.gotoAndStop(1);
currentIndex++;
updateSlide(nextSlideNode);
currentSlideNode = nextSlideNode;
checkImageLoadingStatus();
}
};
next_btn.onRelease = function() {
clearInterval(loadingID);
};
Last edited by bhuddleston; 08-07-2004 at 11:39 PM.
-
a small country village
Ok I've had a small problem up to now with paths when using setinterval.
lets say I have a funtion within movie clip with a path
code:
this.movieClip1.myFunction();
When calling set interval with relative paths I've noticed I have to drop the "this"
code:
clear = setInterval(callFunction, 10);
function callFunction(){
movieClip1.myFunction();
}
but my problem is if I want to call a group of functions
code:
clear = setInterval(callFunction, 10);
function callFunction(){
for (i=0; i<100; i++) {
this["movieClip"+i].myFunction();
}
}
if I use this it doesn't work and if I drop this it doesn't work.. help?? how do I solve this?
-
half as fun, double the price
have you read the first post?
-
a small country village
hi
Yes I have read the article you posted.. I've read it severals time but I can't say that I understand it 100%
So I couldn't really find an answer to my problem. The previous project the probelm I had was that the movie was nested inside another movie clip which also could be variable so absolute addressing wasn't an option. I did manage to do a work around but it seemed very long winded solution.. so I wondered if there was something stupid I was missing.
I apologise if the answer has already been posted but I guess I must be too dum to realise it
anyway if you can point out the answer if there is one I'd be grateful
-
Hi Im wondering if any of you guys who have a better understanding of setInterval could help me out with a problem im having with it. All the info is here:
http://www.flashkit.com/board/showth...hreadid=579706
I've read through the info on this thread but Im still havin trouble understanding what is causing my problem!
Cheers
Rob
-
Another Problem If you may...
I'm making a presentation cd that has a CLIP were inside are frames with stop() action
and a LoadMovie command in each frame for my external SLIDESHOW SWF files
Here's the dilema :
In my External SWF file I have a stop in each frame and a code:
----------------------------------------------
DisplayTime = 5
Countdown = function (message)(displayTime --; if (displayTime == 0){clearinterval(timer);nextFrame();}};
timer=setInterval(countdown,1000);
}
At the end of the slideshow I have one empty slideshow with GotoAndPlay(1)
----------------------------------------------
I have about 30 buttons for each Slideshow
In each frame I also have UnloadMovie.CLIPS.NSlideshow.swf()
It loads the clips but on each new click of another button in Scene
The slideshow becomes faster and faster ...- it pisses me of please
HELP!
_qUILe_
Still_Playing.Starcraft;
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|