AS3 Simple Picture Slideshow
( February 3rd, 2009 )I was thinking about the simplicity of swapDepths() in ActionScript 2.0 and thought that you might be curious as to how one swaps the depths of objects on the stage in ActionScript 3.0.
I have created a practical example which swaps the depths of images on the stage at regular intervals to create a slideshow. I have used the Tween class for the transition effect. My example makes use of:
- setInterval() – Swap pictures at a specified time interval.
- swapChildrenAt() – Swaps the depths of two pictures at specified index positions.
- getChildAt() – Returns the picture at the specified index position.
- Tween() – Used to tween the position of the top picture.
(This file will open in Flash CS3) (Preview File)
Get Source
Posted in ActionScript 3.0, Flash
Thank you.
Everyone else who has tutorials are using tweenlite and stuff like that.
Hey…there some errors popping from the example…maybe an object that is not there has been called.
Thanks. I will try and resolve this A.S.A.P.
how can I make this slideshow to fade in instead?
Hi Karla
Remove or comment out: getChildAt(4).y = stage.stageHeight;
Change the next line to: var picTween:Tween = new Tween(getChildAt(4), ‘alpha’, Strong.easeOut, 0, 1, 2, true);
You can obviously play with the transition strength and time.