SimpleViewer is a great, easy to impliment, polished little gallery written in flash that lets you tie your photos and thumbnails in with XML. It’s got a decent feature set as far as changing the aesthetic of the viewer, but no option for an automated slideshow.
One of my clients wanted this option, and it took me a while to figure it out – so for those of you who are wondering how to incorporate a slideshow into simpleviewer, here’s how!
My finished project can be seen at SixEightyThreePhoto.com
(note – if you’re going for the free version of SimpleViewer this won’t help you – you need access to the source code, so you will need SimpleViewer Pro for this)
Step one – simpleviewer.fla
- Open simpleviewer.fla
- Create a new layer in the timeline.
- Create a keyframe by selecting frame 30 on your new timeline and hitting F6.
- Create your start/stop button and put it here, on this keyframe, on this layer. I’m calling mine ssButton. (for those in the know, I’m not really using a “button” element… I find them awkward to work with… I’m using a MovieClip as a button… but really, either way should work)
- Now we’re going to need a bit of code. This is all pretty simple stuff. A setInterval to iterate the slideshow, and instead of having a boolean to look at to determine whether or not the slideshow is playing, I’m just looking at whether the “play” layer of the button is visible. Open up the actions panel (F9) and copy this…
var nInterval:Number;
ssButton.onRelease = function():Void {
ssButton.mcPlay._visible = !ssButton.mcPlay._visible;clearInterval(nInterval);
if(!ssButton.mcPlay._visible) {
nInterval = setInterval(slideshow, 3000);
sm.ssNext();
}
}function slideshow():Void {
sm.ssNext();
}
Step two – StageManager.as
I wish I knew a better way to do this, but I guess it’s not too painful… What we’re going to do here is pass our function call right on to another class instance. So at the bottom of StageManager, right before the last close brace, add this function…
public function ssNext() {
mImageArea.ssNext();
}
Step three – ImageArea.as
Here’s where we actually, finally, DO something. Place this function right before the last close brace at the end of the file…
public function ssNext():Void {
var nStart:Number = mCurrentImageIndex;
mThumbArea.selectedThumbIndex++;if(nStart == mCurrentImageIndex)
mThumbArea.selectedThumbIndex = 0;
}
Ta-Da!! If you built your button right, you now have working slideshow button in SimpleViewer! You’ll have to publish the simpleviewer.fla file again to get the updated version of your viewer.swf, and then you’ll probably have to tinker a bit to get the button in the right place – but that’s kid stuff.
November 22nd, 2007 at 1:51 pm
Hi.
Do you mind giving us a more step by step description of the first section of your instructions? It would help a lot if you say where to put the code and how Flash 8 behaves after each step you do while editing the simpleviewer.fla file.
Hope you have time to help.
Thanks.
November 22nd, 2007 at 11:16 pm
No problem – I edited the first section to present the instructions in a step-by-step format.
November 23rd, 2007 at 10:22 am
Sorry to be so dumb… but I didn’t understand if the first code snippet should be put:
>> Not dumb – just new! Keep at it!
1 – into the movie clip in “edit symbols” mode when you create it or
2 – into the key frame you created on your new layer or
3 – into the instance of the symbol (movie clip) you are putting into you newly created key frame
4 – elsewhere (so where?)
>> The code goes on the keyframe itself. The keyframe you create on frame 30 of the new layer. Select the keyframe (the one you created by selecting the frame and hitting F6) and hit F9 to bring up the actions panel for that frame. Then paste in the code.
Another thing, please: which properties should we set in the button?
>> The button is simply a movie clip that looks like a button… it’s not a “button component” from the UI components that ship with flash. In other words, it has no special properties to set. Just stick it on the stage with the right keyframe selected, and give it an instance name in the property inspector (use the instance name I did to keep it simple).
Thanks.
November 25th, 2007 at 8:14 am
OK. Now, thanks to your patience, the slideshow starts.
Trouble is I can’t stop it.
I think I haven’t grasped the details of the button (movie clip, OK) creation.
Do you mind telling me in full details how to create that button, please?
How do you get the play/pause effect? Shall I have to create a “play” and a “pause” layer when editing the button and put the two texts (or better, the two symbols) on the two different layers?
What else?
Thanks again.
January 21st, 2008 at 8:10 am
I’m stuck at the same place as fabiospark… how do you make the MC/button function? Everything else in the tutorial works beautifully.
February 6th, 2008 at 7:34 pm
>> OK. Now, thanks to your patience, the slideshow starts.
>>Trouble is I can’t stop it.
>>I think I haven’t grasped the details of the button (movie clip, OK) creation.
Basically what’s going on here is that we are using the setInterval function to advance the slideshow once every X seconds. To stop the slideshow, we need to use the code:
…where nInterval is the variable we use in the setInterval declaration.
Now the button is basically just a movie clip with two layers inside. Each layer is an overlapping graphic, one for how the button will look when it is “on”, and one for how it will look when it is “off”. The bottom graphic doesn’t need to be a movie clip, but the top one does, and it needs to have an instance name of mcPlay (to work with the code above). Also, the whole button needs an instance name of ssButton.
Set things up like that and you should be good to go.
If you need help on creating movie clips and giving them instance names, etc, you need to start by looking for some basic tutorials on ActionScript (the scripting language within flash – a lot like javascript). Don’t worry – it’s not that frightening.
July 11th, 2008 at 10:56 am
Looks great! I do not have Macromedia Flash, I only have SimpleViewer Pro. Am I able to edit simpleviewer.fla without Macromedia Flash? If not, any workaround?
Regards,
Tom
>> You will have to have flash. Sorry!
October 27th, 2008 at 2:32 pm
Saved my life. much appreciated, great work!