Building an auto slideshow with AS3
Actionscript 3, Flash Components, Tutorials January 31st, 2008This time I will show you how you can add an auto slideshow feature to the Slideshow component, using the Timer class.
It’s pretty easy to do this, if you know how to use the Timer class, so I will just show you the code without explaining each step, but if you have any specific question, fell free to ask. Also make sure to read the documentation for the Slideshow component.
-
import com.flashotaku.slideshow.events.SlideshowEvent;
-
import flash.events.MouseEvent;
-
import flash.utils.Timer;
-
import flash.events.TimerEvent;
-
-
var myTimer:Timer = new Timer(1500);
-
-
start.addEventListener(MouseEvent.CLICK, startHandler);
-
pause.addEventListener(MouseEvent.CLICK, pauseHandler);
-
prev.addEventListener(MouseEvent.CLICK, prevHandler);
-
next.addEventListener(MouseEvent.CLICK, nextHandler);
-
-
function startHandler(event:MouseEvent){
-
if(!myTimer.hasEventListener(TimerEvent.TIMER)){
-
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
-
myTimer.start();
-
}
-
}
-
-
function timerHandler(event:TimerEvent){
-
myTimer.reset();
-
myTimer.removeEventListener(TimerEvent.TIMER, timerHandler);
-
mySlideshow.nextImage();
-
if(!mySlideshow.hasEventListener(SlideshowEvent.TRANSITION_COMPLETE)){
-
mySlideshow.addEventListener(SlideshowEvent.TRANSITION_COMPLETE, completeHandler);
-
}
-
}
-
-
function completeHandler(event:SlideshowEvent){
-
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
-
myTimer.start();
-
}
-
-
function pauseHandler(event:MouseEvent){
-
stopTimer();
-
}
-
-
function prevHandler(event:MouseEvent){
-
stopTimer();
-
mySlideshow.prevImage();
-
}
-
-
function nextHandler(event:MouseEvent){
-
stopTimer();
-
mySlideshow.nextImage();
-
}
-
-
function stopTimer(){
-
if(myTimer.hasEventListener(TimerEvent.TIMER)){
-
myTimer.reset();
-
myTimer.removeEventListener(TimerEvent.TIMER, timerHandler);
-
}
-
if(mySlideshow.hasEventListener(SlideshowEvent.TRANSITION_COMPLETE)){
-
myTimer.reset();
-
mySlideshow.removeEventListener(SlideshowEvent.TRANSITION_COMPLETE, completeHandler);
-
}
-
}
The result is this:
Support
As of 11 March 2009, support is no longer provided for the free components. If you need support, please purchase the commercial version of the components.
February 21st, 2008 at 8:15 pm
Hi, how would you implement this so that the slideshow begins to play aoutomatically without pushing the play button?
February 21st, 2008 at 8:55 pm
You could just add
startHandler(null);Make sure to call the function after the first transition is over.
February 22nd, 2008 at 2:22 pm
Thanks! That did the trick.
February 29th, 2008 at 8:13 pm
would it be possible to add a link to the images that are being loaded
February 29th, 2008 at 8:30 pm
yes…you can add the link using the “urlPath” attribute in the XML file…
February 29th, 2008 at 9:20 pm
thanks, i had tried that already, and i am getting nothing. Is there anything i have to add to the actionscript? While im asking questions i couldnt find the correct place to insert the startHandler(null); to play the slideshow automatically.
thanks for the help
February 29th, 2008 at 9:38 pm
your XML file should be like this
<images><img path="images/image0.jpg" urlPath="http://www.google.com"/>
<img path="images/image1.jpg" urlPath="http://www.google.com"/>
<img path="images/image2.jpg" urlPath="http://www.yahoo.com"/>
<img path="images/image3.jpg" urlPath="http://www.adobe.com"/>
<img path="images/image4.jpg" />
<img path="images/image5.jpg" />
<img path="images/image6.jpg" />
<img path="images/image7.jpg" />
<img path="images/image8.jpg" />
<img path="images/image9.jpg" />
</images>
you can add startHandler(null) anywhere outside of the functions
March 25th, 2008 at 10:24 pm
How would I change the transition to correspond to the prev and next buttons? I want it to slide from left to right and right to left depending on the button.
Nice coding!
March 26th, 2008 at 11:04 am
Hi
Try this code:
mySlideshow.transitionEffect = “fly”;
prev.addEventListener(MouseEvent.CLICK, prevHandler);
next.addEventListener(MouseEvent.CLICK, nextHandler);
function prevHandler(event:MouseEvent){
mySlideshow.flyDirection = “left-right”;
mySlideshow.prevImage();
}
function nextHandler(event:MouseEvent){
mySlideshow.flyDirection = “right-left”;
mySlideshow.nextImage();
}
March 26th, 2008 at 3:15 pm
Thanks I got a bunch of syntax errors but it was do to using these ” ” so I fixed it by using these “ ”. Silly code.
March 26th, 2008 at 3:17 pm
Looks like this blog converts all quote marks to the once that flash doesn’t like.
April 3rd, 2008 at 3:26 pm
How can I make this just images transitioning? Maybe3-5 seconds per image….No buttons, just images imported in XML and I can control the effect and the timing, and of course the images.
Thanks in advance!
K
April 3rd, 2008 at 3:45 pm
Hi Ken,
See this example http://flashotaku.com/files/auto_slideshow3.zip
April 11th, 2008 at 4:05 am
Thanks,
Here is my issue: I want to be able to control the transitions. The example was a compiled SWF. I deleted it saved the flas with another name and tried to drag an instance of mySlideshow to the stage. nada. I looked in the AS file and it is connecting to you (like fusekit) that is cool but I only wnated a simple fade and not all the transitions available. If you could help that would be great….Thanks for you hard work.
Ken
April 11th, 2008 at 12:28 pm
Ken,
Use the component inspector to set which transition effect you want or use this code mySlideshow.transitionEffect = “fade”
April 17th, 2008 at 3:25 pm
Is there any way that I can display the image postion in the slide show. Say if there was 20 images there would be a dynamic text field that read “Image 1 of 20″
Any help would be awesome.
Thanks
April 17th, 2008 at 5:03 pm
You can get the index of the current image very easy
import com.flashotaku.slideshow.events.SlideshowEvent;
mySlideshow.addEventListener(SlideshowEvent.SLIDE_INIT, slideInitHandler);
function slideInitHandler(event:SlideshowEvent)
{
trace(event.slide.index)
}
April 17th, 2008 at 8:22 pm
Thanks but what I was looking to do was populate a dynamic text field with info from the XML file. So flash would calculate the total number of image nodes and display which image it was on.
Eg. Image 1 of 20
Image 2 of 20
and so on.
Once again, any help would be awesome.
Thanks
April 17th, 2008 at 9:34 pm
See this example http://flashotaku.com/files/auto_slideshow4.zip
Hope it helps.
April 18th, 2008 at 2:42 pm
Thanks, that works perfectly!!
April 23rd, 2008 at 2:22 pm
Hi this is a really handy component, thanks!
Is it possible to add a random element to this auto slideshow? So it starts on a random image from the xml file and proceeds loading random images, making sure it doesn’t load the previous image twice in a row?
April 23rd, 2008 at 3:50 pm
Hi Tom,
You can load random images. Just use this code. mySlideshow.loadImage(Math.floor(Math.random()*n)), where n is the number of images in your slideshow. However, because of a bug, the first loaded image can’t be random.
April 24th, 2008 at 7:51 am
Hi! Thank you for your hard work and for sharing this great piece of software! I’m doing a little presentation with music and some options for my company and found your component very useful. Thanks a lot.
I have a question too. Do you think it’s possible to make the images pan and/or zoom, so you can add a very dramatic and beautiful effect? As it’s done in the typical slideshows videos you can make with programs like “Memories on TV”, etc.
April 24th, 2008 at 11:46 am
thanks Otaku, but when i slot that script in it gives me this error?:
TypeError: Error #2007: Parameter url must be non-null.
at flash.display::Loader/_load()
at flash.display::Loader/load()
at com.flashotaku.slideshow::Slideshow/loadContent()
at com.flashotaku.slideshow::Slideshow/loadImage()
at slideshow_fla::MainTimeline/frame1()
April 24th, 2008 at 11:51 am
Hi David,
This slideshow component doesn’t have the kind of effects “Memories on TV” has. You can see all the available transition effects here.
April 24th, 2008 at 11:54 am
Tom, when do you get that error? Have you replaced “n” with the number of images in your slideshow ?
April 24th, 2008 at 12:23 pm
Ok, thanks a lot for your kind answer. Keep your great work! :)
April 24th, 2008 at 2:00 pm
hi, yes i have ten images so i replaced the n with 10.
April 24th, 2008 at 3:01 pm
See this example http://flashotaku.com/files/slideshow_rnd_as3.zip
May 7th, 2008 at 1:30 am
Would it be possible to have several instances of the slideshow component running in a row and have them communicate with each other — say, have one image transition happen in one slideshow instance, then another image transition starts in a different slideshow instance when the first one finishes?
May 7th, 2008 at 1:20 pm
You could do that. See this simple example http://flashotaku.com/files/auto_slideshow5.zip
May 7th, 2008 at 5:52 pm
Thanks so much for posting this example– I tried it out and thought of a couple of other questions if you have time:
1) how would I populate a project with more than two slideshow instances (say 8 or more)?
2) how would I insert a pause before each slideshow instance fires off its transition?
3) I know you can randomly order the images themselves, but could you randomize the order between multiple slideshow instances (for example, slideshow instance 1 displays an image transition, then slideshow instance 5 displays and image transition, and so on)?
Also, do you plan to sell versions of the components?
-Kristin
May 7th, 2008 at 9:13 pm
1. You can drag from the Components Window how many instances you want but if you plan to use many instances it would be better to attach them using code
import com.flashotaku.slideshow.Slideshow;
for (var i:int = 0; i < 5; i++)
{
var mySlideshow:Slideshow = new Slideshow();
mySlideshow.x = i* 210;
mySlideshow.xmlPath = “images.xml”;
addChild(mySlideshow);
}
2. You can do that using the Timer class. It’s similar to the example in this tutorial
3. Add your instances to an array and then you could randomly access one of the instances and call the nextImage() method. See if you can work it out. I will post some files later, when I’ll have time.
May 8th, 2008 at 1:33 pm
^ http://flashotaku.com/files/auto_slideshow6.zip
May 8th, 2008 at 5:13 pm
Thank you so much for posting this example!
I worked out my own solution yesterday, but it is nowhere near as complete as yours. I am learning a lot from looking at your code.
thanks again!
-Kristin
May 10th, 2008 at 3:20 am
I have one final question based on the example (auto_slideshow6.zip) you posted — let’s say instead of the one random slideshow in the array playing a transition at a time, I wanted 3 random slideshows playing transitions at a time. I tried to copy the random slideshow function, and calling it in the timerHandler function. It worked initially, but I am missing something that stops the first 3 from playing after the next 3 random ones fire off. Thank you for any help you can give.
May 10th, 2008 at 4:21 pm
Hope it helps http://flashotaku.com/files/auto_slideshow7.zip
May 12th, 2008 at 5:01 pm
Thank you very much for posting the example!
(I can see now why my version didn’t work.)
thank you for all your help!
-Kristin
May 27th, 2008 at 8:00 pm
Refering to “You could just add startHandler(null);
Make sure to call the function after the first transition is over.”
Sorry but, i dont understand where should i put the code. Can you explain me please ?
Thanks for this component!
May 27th, 2008 at 8:47 pm
This is the code that you need to add. You could add this code just before the startHandler function.
mySlideshow.addEventListener(SlideshowEvent.TRANSITION_COMPLETE, firstTranstionHandler);function firstTransitionHandler(event:SlideshowEvent)
{
mySlideshow.removeEventListener(SlideshowEvent.TRANSITION_COMPLETE, firstTranstionHandler);
startHandler(null);
}
June 20th, 2008 at 9:41 am
Hi FlashOtaku..
I modified this gallery, removed the play and pause buttons as well as the functions. I have only 5 images (shouldnt matter if I have less or more). Problem is I get this error (Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found)when I reach the last image and the movie should return to the first image. I get the same error when I click on the previous button when the first image is showing. The auto play also stops functioning when I click on the previous or next button…Can you please help… A million thanks for the component.
June 20th, 2008 at 10:13 am
I fixed the error…just had to edit the xml file sorry…cant figure out how to fix the auto play and loop issue after clicking the buttons
June 20th, 2008 at 10:30 am
Sorry for the continous posts but I just wanted to say I fixed the continous play by using timer reset and delting the stop timer function…thanks again in advanced
June 27th, 2008 at 11:47 am
It is possible to preload all the images before starting the animation instead of preload one at a time?
June 27th, 2008 at 3:51 pm
No, you can only preload one image.
July 22nd, 2008 at 7:05 pm
I’m using swfobject 2.1 to embed your auto slideshow. The swf file receives the absolute path to the xml image list via flashvars.
Firefox and Safari both receive the flashvars and render the slideshow ok. In IE 6 and 7, however, I can output the flashvars to a textfield ok, but the slideshow doesn’t play.
Here’s the AS code:
//flashvars code
var myFlashVar:String;
var varName:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
for (varName in paramObj) {
myFlashVar = String(paramObj[varName]);
}
//textfield
var myTextField:TextField;
myTextField = new TextField();
myTextField.text = myFlashVar;
myTextField.x = stage.width / 2;
myTextField.y = stage.height / 2;
addChild(myTextField);
//set slideshow path
mySlideshow.xmlPath = myFlashVar;
//unchanged Timer and slideshow autoplay code below
//...
FlashOtaku, do you have any idea why IE might be having trouble?
July 23rd, 2008 at 2:15 pm
Hi Richard,
Can you post your javascript code?
July 23rd, 2008 at 4:44 pm
Yes, js below.
The first two swfobjects render correctly. The third, which takes flashvars is the trouble maker.
<script src="/templates/scripts/swfobject.js" type="text/javascript"></script>
<script type="text/javascript">
var flashvars = {};
var params = {};
var attributes = {};
params.wmode = "transparent";
swfobject.embedSWF("/templates/images/ident.swf", "logo", "120", "120", "9.0.0", false, flashvars, params, attributes);
swfobject.embedSWF("/templates/images/testimonials.swf", "testimonials", "360", "100", "9.0.0", false, flashvars, params, attributes);
params.wmode = "opaque";
params.menu = "false";
attributes.name = "flash";
flashvars.imageList = "http://(domain removed)/media/<?php echo $section; ?>/header02.xml";
swfobject.embedSWF("/templates/images/header02.swf", "header02", "778", "186", "9.0.0", false, flashvars, params, attributes);
</script>
July 24th, 2008 at 12:02 pm
It seems that the problem was in the actionscript code. If in your javascript you have
flashvars.imageList = "header02.xml",all you have to do in the actionscript code to get that value is:
var myFlashVar:String = this.loaderInfo.parameters.imageList as Stringand then assign that value to the xmlPath property:
mySlideshow.xmlPath = myFlashVar;You can see it working in this example http://flashotaku.com/files/auto_slideshow8.zip
July 24th, 2008 at 3:23 pm
Hey just wanted to say you made a really awesome slide and the support your providing for all these people is unbelievable and much appreciated. Now as for my question.. I noticed the resizing of the component will actually resize the images i’m trying to use themselves, is there some way to avoid this? thank you for listening..
July 24th, 2008 at 3:50 pm
Oh nevermind found the scaling option in the component parameters in component inspector. Sorry for waisting time! thank you anyways for the great code!
July 24th, 2008 at 4:51 pm
Hi Adam,
Glad you like the component. :)
July 26th, 2008 at 10:37 pm
Yes, thanks for your time and effort on this project.
August 9th, 2008 at 5:19 pm
Hello, exists some way that I can resize with proportionals by Event.RESIZE? I try resize the component but when I compile the movie it do not apear in the screen, but when I resize the window they apear!
August 11th, 2008 at 3:50 pm
That’s strange. Please post some code if you can.
August 15th, 2008 at 6:14 pm
Yep it’s me again….
Is there any way I can make just one set of thumbs from one of the XMLs so that they in turn each can load another XML in the slideshow component that you can scroll through like the one above.
Just to clarify. I click a button. It loads the scroller with thumbnails. I click a thumbnail. Instead of loading just one image from XML it loads a whole new XML, displaying that XMLs first image. Now I can scroll through that slideshow with buttons like above and so on for every thumbnail in the scroller.
If it’s going to mean that I have to redo all of my code I’m just gonna leave it.
Yeah I know. Don’t quit my day job….hehe
August 15th, 2008 at 8:57 pm
First, you would need to edit the thumbnail.xml file.
The nodes should be something like this:
< images path=”thumbnails/image0.jpg” slideshowPath=”images0.xml” >
< images path=”thumbnails/image1.jpg” slideshowPath=”images1.xml” >
…
Then you parse the XML file and store the the paths for the slideshow into an array(exactly how you’ve seen in the other examples), let’s say slideshows.
After that you need to listen for click events and load the corresponding XML file for the slideshow.
myScroller.addEventListener(ThumbnailEvent.CLICK, thumbnailClickHandler);
function thumbnailClickHandler(event:ThumbnailEvent):void
{
mySlideshow.xmlPath = slideshows[event.item.id];
}
Something like that…..
If you need , I could make an example after the weekend.
August 16th, 2008 at 10:43 am
an example would be awesome FlashOtaku. I\’m gonna give it a go on my own anyway…have to get something right once. I\’ll let you know if I pull it off.
August 18th, 2008 at 5:23 pm
Hey FlashOtaku – Awesome stuff you have here! I was wondering how I would customize the slide show to have slide number indicator/button i.e. 1, 2, 3, 4, 5 and so on. So when the slide show is on slide 3, the number 3 indicator/button would be highlighted. To take it even further, lets say a user clicked on the number 5 indicator/button, then that number 5 slide would appear. If the user didn’t click on another indicator/button after that then the slide show would play automatically from its position.
Thanks!
August 18th, 2008 at 6:45 pm
Hi Michael,
See this example: http://flashotaku.com/files/gallery_ex6_as3.zip
I think it’s similar to what you need. It just uses the thumbnail scroller component instead of simple buttons.
August 18th, 2008 at 9:09 pm
Thanks Otaku! Where would I change the transition effect?
August 18th, 2008 at 9:14 pm
Never mind, I answered my own question…
August 19th, 2008 at 6:24 am
No I can’t get it to load the new XML. I give up.
August 19th, 2008 at 11:15 am
Hi franco,
Here’s the example: http://flashotaku.com/files/gallery_ex10_as3.zip
August 19th, 2008 at 4:14 pm
Thank you FlashOtaku. I’m so happy that I’ve come across your page. You have been a great source of information and help. I read somewhere that you have a donation page. Where is it? I’ll go and search for it again.
Thanx again
August 19th, 2008 at 5:16 pm
You’re welcome. About the donation page, it’s not available anymore.
August 25th, 2008 at 10:11 pm
Hey Otaku, In that example you sent me http://flashotaku.com/files/gallery_ex6_as3.zip, when the movie starts up there isn’t a red boarder on the first thumbnail indicating its position… When it moves to the next slide it shows up but not on the first… Is there a way to correct this? Thanks for all your help!
Michael
August 26th, 2008 at 11:29 am
Hi Michael,
That’s strange because it should highlight the first border too. Have you modified anything in the code?
September 3rd, 2008 at 12:34 am
Hey Otaku
First of all love all the great work your doing. My question is an extension on hoppes’ question a while back. I added a url path in the .XML file but when you click on the mage in Safari it opens in a new window and in Firefox 3.0 it doesn’t work at all. Any ideas?
Here is my .XML file
<etc…
September 3rd, 2008 at 12:49 am
sorry “mages” should be “images” in previous post
many thanks
September 16th, 2008 at 12:43 pm
Why cant I use something like this to open the URL’s in the same window?
Is it possible?
Did I do it wrong?
Please help.
September 16th, 2008 at 1:31 pm
Why cant I use something like “target_self” to open the URL’s in the same window – (In the XML-file)?
Is it possible?
Where do I put it, if it is possible?
Please help.
September 16th, 2008 at 2:55 pm
http://flashotaku.com/blog/open-url-when-a-thumbnail-is-clicked/#comment-2027
October 20th, 2008 at 2:31 pm
Hey Otaku
Great work with this slideshow! I have a couple af questions though. Im trying to make your slidehow to work with my design: http://transport.monsun.dk/max/slideshow.png
i need couple of things to make it work..
first of: some way to make the thumbs list as shown in my design “slidehow.png”, and with no scrolling options.
second: a way of adding animated info text to each picture, i want the photographers name and some over all topic for the slideshow to slide in with each picture..
hope u can help :)
best regards
// Max
October 20th, 2008 at 3:51 pm
hey again, i think you have already answered my question about adding text to each picture in http://flashotaku.com/blog/yet-another-image-gallery/
but if possible i would really like to add a colored bagground behind the text, (which would have to be generated dynamic, so it follows the text length) + to be able to animate the tekst, so i can make it slide in from left or something similar.. It might be possible if i could ad the text fields to a movieclip?
October 21st, 2008 at 12:26 pm
Hi Max,
Regarding the thumbnails, that can’t be done with the ThumbnailScroller component. You can only display the thumbnails in one row/column.
For the giving a color to the text fields, use the following code:
myTextField.background = true;
myTextField.backgroundColor = 0xFF0000;
If you want to animate the text field, you can use the Tweener class like I used it to blur the text field. You don;t really need to add the fields to movieclips. Your code should be something like this:
myTextField.x = -300;
Tweener.addTween(myTextField, {x:0, time:.7, transition:”linear”});
November 6th, 2008 at 1:35 pm
Thx! It works wonderfully perfect!
I search for this “trick” since a few weeks…And now i have got found the right entry with anwers;-)
Greets, Flug
January 29th, 2009 at 1:28 pm
Heyh there,
I Googled and this nice slideshow came up… much of it is what im looking for, and when i found read the comments i was thrilled that I could get my hands on different time based effect… but I got no luck with that file, cant see where og how to specify different amounts of time for each picture.
I would like to deffine each transition betwin the pictures aswell…
Are you able to give me a hint on how to put this together??
Thanx in advance
January 30th, 2009 at 3:22 pm
Hi,
I’ve made an example for you which has different delays and different effects for each transition. Here’s the source: http://flashotaku.com/files/auto_slideshow11.zip
February 11th, 2009 at 11:54 am
Hi FlashOtaku,
You component is great. thanks a lot for such a great component and support you give here. If you don’t mind can you guide me how can I make the auto slide show to load the image from where it stopped in another page. I mean, say I have 10 images in the slide show and user goes to a different page with the same slide show. I want the slide show to remember from which image user left the previous page and to load the next image in the slide show in the new page (without loading the sequence from 1st image again) is that possible with a cookie or something? Thanks again for your great support.
February 12th, 2009 at 1:38 pm
Hi Riyaz,
I think it’s possible. You need to use javascript to read data from the flash movie and also to pass data to the flash movie (see flashvars, ExternalInterface). Then you would have to use cookies to pass data across different pages. To load a specific image, you use the loadImage(index) method.
February 12th, 2009 at 10:47 pm
Hi,
I was wondering if there was a way to add JPEG or Bitmap smoothing to the images if they are scaled!
something like this:
var bitMap = Bitmap(largeImgLoader.content);
bitMap.smoothing = true;
thanks so much!
February 13th, 2009 at 1:15 pm
Hi,
The slideshow has a ‘smoothing’ property that you can set using the Component Inspector or using code : mySlideshow.smoothing = true.
February 15th, 2009 at 7:11 am
Hi FlashOtaku,
Thanks a lot for your reply. I found a class which can write a cookie in client machine and retrieve it. In this case I guess I can get away without the Javascript or flashvars. I’ll try it with the loadImage(index) function you have mentioned. If I could do it successfully I’ll post it here for you to see. thanks again for the support.
February 15th, 2009 at 7:37 am
Hi FlashOtaku, Sorry for posting again. Is there a way to make the first image in the list -when I load the swf movie – to just appear without any transitions? that can be loaded from anywhere from the list (by a cookie) Thanks a lot.
Regards,
Riyaz
February 16th, 2009 at 6:40 am
Hi FlashOtaku,
Following is the code I’m using for the automatic slide show and it’s working smoothly without any errors. If I try with your method ‘ loadImage(index) ‘ I get some errors. Can you tell me where should I call this method to load the image I want and to start the slide show from that?
Thanks a lot in advance.
Riyaz
—————————-
import com.flashotaku.slideshow.events.SlideshowEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
var myTimer:Timer = new Timer(2000);
mySlideshow.addEventListener(SlideshowEvent.TRANSITION_COMPLETE, transitionCompleteHandler);
myTimer.addEventListener(TimerEvent.TIMER, timerHandler);
function transitionCompleteHandler(event:SlideshowEvent)
{
myTimer.start();
}
function timerHandler(event:TimerEvent)
{
myTimer.stop();
mySlideshow.nextImage();
}
February 17th, 2009 at 6:32 am
Thanks so much!!! You are awesome!! Great work on everything!
February 17th, 2009 at 1:14 pm
Riyaz,
First, you need to set the ‘autoLoad’ property to false. Then, only call the ‘loadImage’ method after the XML file has completely loaded:
mySlideshow.addEventListener(SlideshowEvent.XML_COMPLETE, xmlCompleteHandler);
function xmlCompleteHandler(event:SlideshowEvent):void
{
mySlideshow.loadImage(5);
}
If you want the image to appear without any transition set the ‘transitionEffect’ property to ‘none’.
February 17th, 2009 at 5:48 pm
Hi,
I’m getting an error using the “mySlideshow.smoothing = true;” tag. as well, i’m not seeing the option in the component properties to change it. I am using “auto_slideshow3″.. but i also looked at auto_slideshow11 and i’m not seeing it there either.
thanks for all your help!
February 18th, 2009 at 10:42 am
Hi FlashOtaku,
Excellent. It works perfectly now. Thank you very much for your replies and great support.
Riyaz
February 18th, 2009 at 4:01 pm
Riyaz,
You’re welcome.
Daniel,
That file has an older version of the component. Download the latest version from this link and replace it in your file.
February 18th, 2009 at 9:12 pm
Hi again,
I tried replacing it with the Slideshow_As3 file you refered me to, but i’m still getting an error. As well, i tried using that mySlideshow.smoothing = true; within the slideshow as3 and i got the same error. Sorry for the trouble! But thanks for your help!!!
cheers
February 18th, 2009 at 10:55 pm
The slideshow from the slideshow_as3.fla file is also an older version. You need to install the new version of the component using the Slideshow AS3.mxp file. After you’ve installed the new version, simply drag an instance of it from the Components Panel into the Library. See this instructions: http://flashotaku.com/forum/viewtopic.php?f=3&t=5
cheers
February 22nd, 2009 at 3:21 am
Hello my name is Apollo I love This Slideshow component …….you are great……
enough sucking up..lol ….I’ve been looking for some answers about your component but nothing
about my problem …..i have the slider conneted to my mp3 player so that when the buttons are pressed the slider
moves to the next pic but i have an auto mp3 player so when the player switch songs the slider don’t…can you help….
i don’t see a way i can load the mp3 as. file so you could check it out…….so I’m gonna paste it up here with your permission.
Apollo…..
P.S. Thank You for all your hard work . I’m not smart like you……..I make music….. Peace And Good Flashing
February 22nd, 2009 at 4:07 am
Hello….Apollo Here… i’ve solved my problem …thanks anyway…..peace…
February 23rd, 2009 at 7:30 pm
Glad you’ve worked it out :)
February 23rd, 2009 at 10:29 pm
yes but now i have another problem……when the swf loads into the slide show . the swf don’t completely load up…like i have dynamic buttons in the swf but they don’t load into the slide show with the rest of the swf……do you have any idea what’s going on………..every thing else work just that ….thanks peace….
February 24th, 2009 at 1:02 am
sorry the problem is on my end…the swf i’m loading has bars that stretch out and your application rescales it, thus making it too large or squeeze up …i need a new rating system for my mp3 player
thanks…….if you know where a tutorial on a 5 star rating application or a good poll system let me know ….
Flash AS3 only…….php to flat file database ……no mysql……
thanks again sorry for wasting your time…..
this is what i want a mp3 player that people can vote on the music……
and a new vote pop up when the music change……..
March 6th, 2009 at 4:00 am
Great component, is there way to randomly load an image, and after the image is loaded not load it again until it has randomly cycled through all the images in the xml file?
March 6th, 2009 at 12:08 pm
Please read the above comments. There should be a similar example posted.
March 9th, 2009 at 5:09 pm
Okay, I used some code similar to this for a random slideshow I am creating for my company’s website. I need more control over the “randomization: though. Right now, it sometimes plays the same image 2 or 3 times before it moves on. Is there any way to play all of the images before going random??
March 9th, 2009 at 5:15 pm
Sorry, forgot to add the code I used… See I don’t want any buttons (start, next, etc) just a random slideshow that calls the images from an XML file. It works fine, I just want it to go through them all before repeating… Can anyone help??
import mx.transitions.Tween;
import mx.transitions.easing.*;
pauseTime = 5000;
xmlImages = new XML();
xmlImages.ignoreWhite = true;
xmlImages.onLoad = loadImages;
xmlImages.load(“images.xml”);
function loadImages(loaded) {
if (loaded) {
xmlFirstChild = this.firstChild;
imageFileName = [];
totalImages = xmlFirstChild.childNodes[0].childNodes.length;
for (i=0; i<totalImages; i++) {
imageFileName[i] = xmlFirstChild.childNodes[0].childNodes[i].attributes.title;
}
randomImage();
}
}
function randomImage() {
if (loaded == filesize) {
var ran = Math.round(Math.random() * (totalImages – 1));
picture_mc._alpha = 0; // Start image clip as invisible
picture_mc.loadMovie(imageFileName[ran], 1); //Load random image from xml
var pictureTweenIn:Tween = new Tween (picture_mc,”_alpha”,Normal.easeIn,0,100,3,true); // Use the Tween class to ease in the alpha from 0 to 100 over 1 seconds
pictureTweenIn.onMotionFinished = function () { // When done fading
_root.pause(); // Start pause() function
}
}
}
function pause() {
myInterval = setInterval(pause_slideshow, pauseTime);
function pause_slideshow() {
clearInterval(myInterval);
var pictureTweenOut:Tween = new Tween (picture_mc,”_alpha”,Normal.easeOut,100,0,1,true); // After pause, start fade out
pictureTweenOut.onMotionFinished = function () { // Once faded out
_root.randomImage(); // Call next randomImage()
}
}
}
March 10th, 2009 at 12:07 pm
You could have a function to generate unique random numbers.
var usedNumbers:Array = [];
var ran:Number = getRandom();
function getRandom():Number
{
var random:Number = Math.floor(Math.random * totalImages));
while(usedNumbers.indexOf(random) != -1)
{
random = Math.floor(Math.random * totalImages));
}
return random;
}
I haven’t tested the above code but it should be something like that.
March 24th, 2009 at 1:41 pm
Hi!
I really would need som help! I have downloaded your gallery, and i really love it! But i need to load external swf:s also, is it possible?
Than i also (sorry=)) need to add links/text to the dynamic images (like mailto) … do you think you can help me with that?
Thanks! I really appreciate it!
March 24th, 2009 at 2:44 pm
Hi,
I appreciate that you like the component but this free version is no longer supported.
What you try to achieve is possible but you need the commercial version, which you can find here, to get support.
March 25th, 2009 at 8:20 am
Oh, sorry! Thanks anyway. This i a small schoolproject so I can´t buy it right now. But I come back when I need something in the future, really like the stuff you make=)
August 21st, 2009 at 9:13 am
Your slideshow goes very fast from one pic to another. How can I reduce the speed?
thx!
August 21st, 2009 at 9:14 am
Your slideshow goes very fast. How can I reduce the speed?
thx !