PDA

View Full Version : pic slideshow - loop problem


psfream5
09-19-2011, 06:15 AM
Hi,
I want to do a simple slideshow in flash where the images fade into each other when the user clicks on the image. I have 4 images and I'm using labels and telling flash to go to the next label on each click. However, the problem is that it does not loop properly. I want it to cycle the 4 images in the order I specify indefinitely, should the viewer keep clicking. It's supposed to go 1-2-3-4-1-2-3-4-1-2-etc..., but right now it just goes 1-2-3-4-1-2-3 and stops at the 3rd image on the second pass.

I'm confused why this is because it played through once fine and the same instructions are there to tell it to continue but it stops on the 2nd pass through.

I did try to link the FLA and SWF file in this post but it seems I cannot because I don't have the requisite number of posts. I have a JPEG attached to show what I have in my FLA file if anyone can see anything obvious that would fix this problem.

Any idea on how to solve this seemingly simple problem? I tried everything I could think of to no avail. I would appreciate any help.

Thank you.

xdeath
09-19-2011, 09:21 AM
i'm not sure if your aware but the frame labels are a frame ahead of the code. also your picture doesn't show the code for the last frame...

psfream5
09-20-2011, 01:32 AM
I checked and the pic does show the last frame?

Also, I believe it's okay the way the labels and frames are set as there's a stop command at the end of the animation and the code is there to tell it on click to go to the next label. I believe that part is set okay because the first pass (1-2-3-4) looks as intended, only that on the 2nd pass it locks up. It's curious because the 2nd pass is calling the same code as the 1st pass.

i have the SWF file here so you can see it in action:

tss2ml (dot) net16 (dot) net/test.swf

i also have the FLA (CS4) file here:

tss2ml (dot) net16 (dot) net/test-cs4.fla

I appreciate any help.

xdeath
09-20-2011, 03:20 AM
well you had some code on the main timeline that was causing it to screw up.

other then that it seems fine. i've attached a fixed version for you.
(note i added numbers so it was easier to tell what square you were on)
and for the record that picture you had on your first post showed you selecting the last frame but didn't show the code for it.

i downloaded the picture and everything, so don't lie!

psfream5
09-20-2011, 03:40 AM
thank you!

i think when i made this, i formatted it after something else i saw online and ran into some trouble. what you did here seems cleaner and much easier to read. i will spend some time to look at how you created it to better understand, but this is in fact what i wanted it to do, so thank you very much for this!

and the attachment jpeg file, i really didn't change the jpeg attachment? so i'm not sure what happened there. but in any case, this helped a lot for me and possibly others who are looking to do the same. we can look at the code to see the structure which helps us learn!

thank you sir!

xdeath
09-20-2011, 03:55 AM
thank you!

i think when i made this, i formatted it after something else i saw online and ran into some trouble. what you did here seems cleaner and much easier to read. i will spend some time to look at how you created it to better understand, but this is in fact what i wanted it to do, so thank you very much for this!

and the attachment jpeg file, i really didn't change the jpeg attachment? so i'm not sure what happened there. but in any case, this helped a lot for me and possibly others who are looking to do the same. we can look at the code to see the structure which helps us learn!

thank you sir!
no, prob. glad i could help ;)

psfream5
09-24-2011, 10:04 AM
no, prob. glad i could help ;)

i ran into a new problem which i suspect is an easy fix but can't figure out.

so xdeath, once again, thanks so much for your earlier help - you got it to do what i wanted originally.

now, i want to make a slight tweak to the pic slideshow, where it shows pic 1 for X seconds, then automatically fades to pic 2 which shows for X seconds, and then fades to pic 3 which shows for X seconds, then fades back to pic 1 to start the whole process all over again.

you can see what i have here:

tss2ml.net16 (dot) net/test2.swf

i also have it set in the code that when someone clicks on the pic, it will automatically jump to the frame where the fade-in starts for the next pic so the viewer doesn't have to wait X seconds to advance.

as seen in the SWF file, the code works for only the 1st pass. after the 2nd pass, when you click the picture, it seems to jump back to the first frame. i seem to be having the same problem as earlier wherein that the code seems to work fine for only the first pass, and when it starts to loop, then the code doesn't function properly. i don't see why this is.

the FLA file is here:

tss2ml.net16 (dot) net/test2.fla

any help would be appreciated.

thanks.

ionLemming
09-25-2011, 07:47 AM
>_< timeline code!

... you are adding event listeners without removing the previoius one and its messing up when it stacks...

remove the previous mouse event listener before adding another one...

and...

don't code on timeline : )

ex:

frame 1:

removeEventListener(MouseEvent.CLICK, buttonClickslide4);
addEventListener(MouseEvent.CLICK, buttonClickslide1);

function buttonClickslide1(event:MouseEvent):void{
gotoAndPlay("F1");
}


frame 34:

removeEventListener(MouseEvent.CLICK, buttonClickslide1);
addEventListener(MouseEvent.CLICK, buttonClickslide2);

function buttonClickslide2(event:MouseEvent):void{
gotoAndPlay("F2");
}



frame 77:

removeEventListener(MouseEvent.CLICK, buttonClickslide2);
addEventListener(MouseEvent.CLICK, buttonClickslide3);

function buttonClickslide3(event:MouseEvent):void{
gotoAndPlay("F3");
}



ect...

psfream5
09-25-2011, 08:43 AM
great, it works! thank u ionlemming!

and what do u mean, don't code on timeline? how else would i do this?

ionLemming
09-25-2011, 05:06 PM
made this kinda quick but just trying to show an example... might look like a lot at first ... but you don't have to have 10,000+ frames on your timeline to show a ton of images

psfream5
09-25-2011, 06:05 PM
wow, that does seem like quite a lot. at least for me since i'm not all that familiar with the coding part.

is there an advantage of doing it the way you did?

could i just do it with the timeline, as that seems a lot more intuitive and easier for me? or will i hit limitations or other problems later?

ionLemming
09-25-2011, 06:28 PM
just showing you a better way to do what you're trying to do... if it's something really small like 5-10 images go ahead and do it on the timeline .. but imagine having to make 20+ different slideshows all with different speeds and different image counts and transitions ?

(timeline)if you want to change the speed that the images stay up or fade in at you have to add a bunch of frames in between each and every image transition (if you have 100 image transitions you see where the problem is...
(.as code) just change variables fadeTime or switchTime to a different number

(timeline)-if you want to add more images you have to add more timeline frames for
every image
(.as code)- you just add to your imageArray

(timeline)- if you have several projects with several types of image gallerys / slideshows ... 1- ur gona have a ton of frames in every one of your projects 2- if you want to modify something you have to add / delete a bunch of frames in each and every project...
(.as code)- if you make this into a class you just have to build it once and you can use it in as many projects you want ... and have a centralized way to update everything (or modify alot easier by extending)

psfream5
09-25-2011, 06:36 PM
thanks for the specific examples. what you said makes sense.

i guess at some point i will have to learn the way you described for more complicated projects.

thanks for all your help ionLemming.

xdeath
09-26-2011, 02:02 AM
so if this is solved i suppose you don't need my help?

if i understand what ionLemming is trying to say, then i have to say i agree. when i help i simply help fix other peoples problems. so i don't try to change what and how they do things unless it becomes a problem.

however when you become better at programming you will realize you do everything from just one frame. or well for the most part anyway.

psfream5
09-27-2011, 07:16 AM
yeah i'm good for now, thanks xdeath. appreciate you checking back though!

thanks a lot to both you guys, xdeath and ionlemming!