Simple ActionScript 3 Slideshow Engine

Simple ActionScript 3 Slideshow engine. This class file simply creates a slideshow that in its current setup, cross fades between each image. The class uses external images and is in fact, abstracted from sourcing any images. It is up to you to provide the class with an array of image URLs for it to use. This is a reworking of an earlier class, which has now been removed from this site.

Class currently uses tweenLite to handle the alpha transitions. However, this is simply replaced via a simple timer function. But I’ve left tweenLite in the class so that people can change the transitions to other types, like, blur, photoFlash etc easily by changing the tween type. If you just want an alpha fade and don’t use tweenLite elsewhere in your project, replace the tweenLite functionality with your own alpha fading transition. An example of which, is commented out in the class source code.

Class settings are instance based, which you access via getters/setters. So you can have muliple slideshow instances running at the same time

Class Features

  • External Images
  • Control over image cross fade time
  • Control over image display time
  • Linear or random image progression
  • Automatic (timer) progression, or via mouse event
  • Looping or play once
  • Pause / Resume the slideshow in auto mode

Via setters, you can access and set the following properties for each slideshow instance..

xFadeTime: get/set – DataType:uint – Sets crossfade time or transition time between two slides in seconds
imageTime: get/set – DataType:uint – Sets total image display time, not including xFadeTime in seconds
slidesPlayRandom: get/set – DataType:Boolean – Sets the linear or random play order for slides. Set to true for random playback.
slidesLoop: get/set – DataType:Boolean – Sets whether the slideshow loops, or stops at end of images array. True = looping
slidesAutoPlay: get/set – DataType:Boolean – Sets whether the slides use the timer to auto progress, or whether a user must click on the slides to progress. True = autoPlay

Look in the demo .fla’s document class for examples of listening for the classes various events. You can listen for Open, Progress, Complete and SlideShowComplete events at the class instance level. You can also dispatch a pause and a resume event to the class. Which will pause / resume the class if it is in automatic mode.

View Example
http://www.noponies.com/dev/as3_xslideshow/

Source Files
http://www.blog.noponies.com/wp-content/uploads/as3_xslideshow_1_2.zip

Dependencies
tweenLite

41 Neighs about “Simple ActionScript 3 Slideshow Engine”



NEERAJ Neighed:

hii,
can we create same slideshow without using xml or flashvars,
i need that the image will readed from a one single directory,if we update or delete somthing flash will work accordingly.

is it possible

thanks,
neeraj

Dale Neighed:

Sure, you would have to use a PHP or similar solution to parse the directory for files.

Roman Neighed:

Hey,

great thing. It would be really nice if you could add controls to it and a loading status of the current loading image. Controls like
stop the slide show, start the slide show.

have a look at this website and it?Ǭ¥s slide show feature

http://www.sasokos.com/

Greets,

Roman

Dale Neighed:

Roman,

The class is meant as a base example that can be extended on. It already supports a progress event for each slide loading. I have demonstrated in the demo how to hook into that event. For pausing and starting, simply adjust the classes timer interval.I added in a pause / resume event pair for pausing and resuming the slideshow.

Mike Neighed:

I can’t view the flash after embed. But I can view the flash by directly type the full URL SWF path. What’s wrong with me?

Dale Neighed:

Mike,

NO idea.

Nick Neighed:

glad to see you switched back to this layout! It’s much nicer :)

Dario Gutierrez Neighed:

Awesome slideshow engine, thanks for sharing!! Oye Dale, if i modify your flash source, can i publish it in my blog?

Dale Neighed:

Dario,
yeah thats fine. Just put in a credit etc. Be interested to see what you make.

Dario Gutierrez Neighed:

Thanks Dale, i will tell u when publish it!! Best Regards from Mexico.

Budy Neighed:

Hi Dale,

If I want to use this slideshow without using xml and php, just point to specific folder, how difficult to do it? Do you mind to show me how to do it in simplest way? The main reason why I want this is currently I have a project, and it requires to update the content from the directory (a folder), then every six hours, they will change the images (6 images) by replacing the old images.

Hope you can help and really appreciate it!

Thank you so much.

Budy

meowsk Neighed:

I am curious if it is possible to have the images fade out like they fade in. I have several different sized images in my slide show so when a smaller one shows up over a larger one the on in the back just disappears without any fading.

kai Neighed:

I’m still a poor student so I can’t afford much but I’ve sent you what I can. To be honest, it’s not just because I’ve used this bit of flash (twice) but because I really do respect people who take the time to write concise code. And not just that but it’s easy to use (which takes good planning to achieve) and has notes that are all useful. Cheers. Buy yourself a good meal along with a tasty beer :)

Dale Neighed:

Kai,

Thanks a lot. Your support is very appreciated. :)

Niklas Neighed:

Hi there!
Love the stuff you have here..!!
I have a question – does anyone know how would you go about to have the lower right corner fixed instead of the top left one? That way the image would still be cropped when needed but on the left side instead…

All the best, Nikals

John Neighed:

Howdy,
I just got your Full Browser XML Slideshow working, and out of curiosity i checked the rest of your blog and found this script. I have a few question:

1. How is this script different than FullBrowserXShow class you published in Feb 2008?

2. Is this new class meant to replace FullBrowserXShow class, or were you referring to a different outdated script at the beginning of this post?

3. Would you recommend using this script instead for a simple fullscreen slideshow?

Thanks and great work,
John

Dale Neighed:

John,

The only difference is the fullScreen element of it.

The reference to the older class was about a version of this particular example, that I reworked to better handle memory and improve the overall structure etc.

For a simple fullScreen slide show, I’d still use the other fullBrowserSlideshow example. You could use this one, but you would have to implement the resizing to browser size etc.

A future update to most of the fullscreen classes etc here will abstract out the fullScreen elements of each class. I’ve written a more modular class that takes any display object and resizes it to fullScreen. Once I post that, you will be able to simply plug in content as you see fit, and have it scale to full browser size etc. Its all part of the fullScreen video demo I’ve been working on, and taking too long to finish. :)

Byron Neighed:

Thanks for the clean script. In response to the folks above who want the old slide to fade out, add ‘onStart:oldSlideAlpha’ to the TweenLite function, then paste the following function right before the onFinishAlpha one:

function oldSlideAlpha():void {
if (contentHolder.numChildren>1) {
TweenLite.to(contentHolder.getChildAt(0), crossFadeTime, {alpha:0});
}
}

This will crossfade the old slide for the same duration as the new slide fade-in

Byron Neighed:

Oops! I forgot to mention that the tween function is located on line 212 of the Xslides.as file. :)

ActionScript 3.0 Image Galleries « Bauhouse Neighed:

[...] Simple ActionScript 3 Slideshow Engine [...]

Nabil Neighed:

Hi , thx for the slideshow
i get an error when i try to remove the xslides from the display list
newSlides = new Xslides(imgNames);
.
.
.

removeChild (newSlides);

err:”There was an error when attempting to delete all slide content: class [error]”
ot seems this is the culprit: //loader.unload(); inside removedFromStage

thx any ideas?

Dale Neighed:

Nabil,

Yeah, I knew about that error and had fixed it, but had not quite uploaded it to the site.

I’ve uploaded it now, but if you just wanted to change your version; Remove that unload call from the RemovedFromStage handler and add in this..

[cc lang="actionscript" tab_size="2" lines="60"]
if(loader !=null){
loader.close()
}
[/cc]

The version I’ve uploaded also kills any running tweens, which can also cause an issue when removed from the stage, as tweenLite will continue to tween and then look for an object when it completes is tween, which of course is no longer there, and throws and error.

Nabil Neighed:

Awesome Dale- thank you so much for getting back to me so quickly i should have also thought about it too -but thx and i ll download your latest files.

Nabil Neighed:

Hi – is there a way to just cached the images after the slideshow has done rotating once ? instead of loading again the same images ?thx nabil

Dale Neighed:

Hi,

No, no method to cache the images.

Joel Neighed:

This is really awesome. I was having a huge issue with getting a good crossfade in Flex. I changed your class to extend UIComponent, and it works like a dream.

Cheers.

Bernhard Neighed:

Hi thanks for sharing this cool viewer!

Is it possible to add urls to the images you load?

Cheers.

Dale Neighed:

Bernhard,

No, that functionality is not present at the moment.

Empas Neighed:

Thank you very much for your script. It helps a lot to all of us that are moving from AS2 to AS3!!

Cheers.

batbox Neighed:

Hi i would like to know how to load an external movie, above the sliding images, on this example… can someone help??

mike Neighed:

is it possible to use SWF files instead of images OR can i use both images and SWF files.

Dale Neighed:

Mike,

It only supports bitmaps at the moment. I’ve been meaning to update it.

Brad Neighed:

Great swf!

One question, I can not get the swf to “play” in my absolutely positioned div. I currently play a swf intro and give visitors the option to skip or replay it. This all works, but the swf is at position 0, 0. How do I get it tto play in the div with id movie like on the club’s live page: http://www.hcca.org/index.html

My Flash skills are week, I tried creating this with a motion tween, but your version is much better. I saw someone mentioned making a “donation”, that seems more than fair for this great app, assuming I can get it to work. Again, thanks!

Also, thanks for providing the source class, I will try to learn from it. Note, if you load indexT it will pop an alert with movie’s x and y coordinates.

Brad Neighed:

OK, I tried looking at the FLA. First, I just wanted to resize the movie to 400 / 300. However after doing this when I try to publish, I get several errors in AAS3_CrossFaade.as:

Line 20, Type not found or was not a comppile time constant loadxml

The same error on line 21 for Xslides

Also, there are errors that the definitions for the above can’t be found. A path problem perhaps?

My lack of knowledge is showing. How do I change the size to 400/300? Instead of random photo display, would it be possible to have a random start position, but retain the order?

Is it possible to point the one swf to different images.xml files for different slide shows?

Thank you for helping a newbie learn. I’m using Flash Pro CS3.

Brad Neighed:

I really should organize my thoughts … I fixed the path errors. I modified the .as files and changed the fade and pause speeds. This looks great. Again, thanks for the comments.

I loose my ‘movie’ div after launching the javascript function to load the swf. The pre and post call alerts in the page linked to show this. You referenced an id of movie it appears, so I renamed my movie div to hccamovie, but this did not resolve the issue. Any ideas on how to get the swf properly positioned in the hccamovie div would be greatly appreciated.

Thanks for a great app

Chris Neighed:

I really love this slideshow code! I’ve just made the transition to AS3 and this has been very helpful for learning. My one question though is, how can I add in titles and descriptions?

antonio brandao Neighed:

The only thing I find missing really is the function for “next slide” and “previous slide”. Other than that it’s a perfect solution. I’m attempting to implement that functionality myself now

antonio brandao Neighed:

nextSlide() was easy, previousSlide() still not working well

Cooper Neighed:

Great slideshow! Does anyone have a next/previous button solution that they would be willing to share? That would be extremely useful.

softpix Neighed:

Really nice slideshow. But I’m missing next/prev buttons… Is it possible to implement this functions?

Alrick Telfer Neighed:

Thanks, it was really helpful!

AT

Leave a neigh?