
The code is AS3 and the tutorial assumes some general knowledge of flash and actionscript 1 and 2.
The table of Contents is as follows:
- Class usage
- Loading and parsing the XML
- Loading the images
- Adding to Stage
- Animating
- Finishing Touches
- Complete Code and Downloads
Class usage
We’re aiming for simplicity here, so reducing the code to minimum, to create a new slideshow, you’d write this in a new .fla frame:
var slideshow:Slideshow = new Slideshow("list.xml"); addChild(slideshow);
The first line should create an instance of the Slideshow class, while the second one would simply add it to the Stage (no more attachMovie!).
Therefore, the barebone structure of our class will look like this:
package { public class Slideshow extends Sprite { import flash.display.*; public function Slideshow(datasource:String) { } } }
Doesn’t really do much for now, does it?
As you can see, in AS3 we need to specify the package for the class. If you’ve worked with packages in AS2, instead of writing something like
class com.widgets.Slideshow { ...
you now write
package com.widgets { class Slideshow { ...
In this tutorial we won’t be using fancy packages, because the Slideshow is not part of a bigger framework – although you’re free to integrate it in one.
Note how we’re importing the flash.display package so we can extend the Sprite class. By the way, Sprite is a new kind of MovieClip without timeline (technically MovieClip extends Sprite by adding timeline functionality) but the point is that if you don’t need your clip to have multiple frames, you’re better off with a Sprite as it uses less RAM.
On the next page, we’ll see how to load and parse the xml that contains the image list.
I’m having a serious problem that’s just recently appeared. my flash cs3 is unable to build a classpath to the external actionscript in your tutorial example as well as others I’ve downloaded tonight. it’s driving me crazy. have you ever encountered this?
my program was corrupted. had to re-install from scratch. fine now!
thanks for this terrific example….
This was dead on and will really help out. Thanks for the time and effort to detail the code. Mahalo!
Spot on. Very useful. Thanks
This is great I’m new to actionscript and this was very helpful. It looks really nice. I was wondering, how do i go about making the images ‘clickable’?
Thanks
Excellent presentation Armand. I
Awesome flash based slide show, great work explaining it step by step as well. Thanks for sharing, keep up the good work.
Thank you very much for the tutorial, especially the pdf and full code. I linked you to where I will use it and cite for credit. Thanks!
Excellent tutorial, Armand. I will share this link with my design students. Thanks much.
This is the best tutorial/example I’ve found on the subject.
One thing you could do different is to keep the image source and title strings directly in the XML object, since it is already loaded in memory, no reason to create another copy of it in memory. A slideshow is a linear arrangement but frequently the user can jump around so it isn’t necessary to have things in linear order. You end up using the id names. If you have a large number of images, say your slideshow totals into the 100’s of megs, it may be better to load them on demand, not all at once.