Image Gallery Tutorial (Example 2)
Actionscript 3, Flash Components, Tutorials January 16th, 2008In this tutorial I will create another image gallery. This time I will show you how you can create image galleries using only code. This gives you more flexibility when you use these components in your projects.
1. Import the Slideshow and ThumbnailScroller class. You need to import these classes to be able to create instances of the components by code.
-
import com.flashotaku.slideshow.Slideshow;
-
import com.flashotaku.thumbnailscroller.ThumbnailScroller;
2. Import the ThumbnailEvent and MouseEvent class. You need these classes for navigation.
-
import com.flashotaku.thumbnailscroller.events.ThumbnailEvent;
-
import flash.events.MouseEvent;
3. Create an instance of the Slideshow and change some properties.
-
var mySlideshow:Slideshow = new Slideshow();
-
addChild(mySlideshow);
-
mySlideshow.xmlPath = "images.xml";
-
mySlideshow.setSize(380, 260);
-
mySlideshow.x = 95;
-
mySlideshow.y = 10;
-
mySlideshow.setBorder = true;
-
mySlideshow.borderThickness = 5;
-
mySlideshow.preloaderType = "circular";
-
mySlideshow.transitionEffect = "squares";
-
mySlideshow.squaresEffectType = "blur";
-
mySlideshow.squaresDirection = "random";
4. Create an instance of the ThumbnailScroller and change some properties.
-
var myScroller:ThumbnailScroller = new ThumbnailScroller();
-
addChild(myScroller);
-
myScroller.xmlPath = "thumbnails.xml";
-
myScroller.setSize(500, 70);
-
myScroller.x = 34;
-
myScroller.y = 307;
-
myScroller.setBorder = true;
-
myScroller.borderThickness = 3;
-
myScroller.easingType = "Back";
-
myScroller.easingMethod = "easeInOut";
-
myScroller.moveAmount = 200;
5. Create 2 movie clips that you will use to move the thumbnails to left and right. For my example I’ve created a triangle. The triangle is in the library and has the Arrow class associated with it (To understand this step you need to know how to import movie clips from the library in Actionscript 3. The tutorial doesn’t cover this but I will explain it to you if you need).
-
var left:Arrow = new Arrow();
-
addChild(left);
-
left.x = myScroller.x – left.width – 5;
-
left.y = myScroller.y + (myScroller.height – left.height)/2;
-
-
var right:Arrow = new Arrow();
-
addChild(right);
-
right.rotation = 180;
-
right.x = myScroller.x + myScroller.width + right.width + 5;
-
right.y = left.y + right.height;
6. Add event listeners for the “left” and “right” movie clips.
-
left.addEventListener(MouseEvent.CLICK, leftHandler);
-
right.addEventListener(MouseEvent.CLICK, rightHandler);
-
function leftHandler(event:MouseEvent){
-
myScroller.moveLeft();
-
}
-
-
function rightHandler(event:MouseEvent){
-
myScroller.moveRight();
-
}
7. Add the code that will open an image in the slideshow when a thumbnail is clicked
-
myScroller.addEventListener(ThumbnailEvent.CLICK, clickHandler);
-
function clickHandler(event:ThumbnailEvent){
-
mySlideshow.loadImage(event.item.id);
-
}
That’s all. Enjoy. Feel free to ask anything you don’t understand.
Download sample files for Actionscript 2
Download sample files for Actionscript 3
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.
January 22nd, 2008 at 9:12 am
You are a God.
Thank you very much, I have been looking for a month anything like this slideshow.
Richard
January 22nd, 2008 at 9:34 am
I’m glad you like it :)
January 24th, 2008 at 2:51 am
Hi!
There’s one thing that I don’t understand… Are you human!!!
I’m so impressed by your work!!!
I’m on a project for which this slideshow would be marvelous… Is it possible to use it???
Also I’m searching for some kind of slider with the elastic effect. Here’s an example in AS2 :
http://www.reflektions.com/miniml/template_permalink.asp?id=237
If you could help me…
January 24th, 2008 at 3:17 am
I’ve just checked the Donate page… I would gladly donate if you could help me with my problem concerning the slider… I promess… And this promess will stay as a reply on this page, so…
January 24th, 2008 at 8:35 am
Hi Nick, of course you can use this slideshow. As for the slider, I think you could use the ThumbnailScroller component to build it.
January 24th, 2008 at 9:23 am
See this slider that I’ve built using the ThumbnailScroller component slider_as3.zip
January 24th, 2008 at 5:27 pm
No it won’t works! My client wants it very smooth and clean… I was surprised that he liked it with that little “swing”! But for another job it might fit… Thanks for your time…
January 24th, 2008 at 6:04 pm
That was just an example…i don’t know exactly how you want your slider to be but maybe you should play a little with the ThumbnailScroller component, read the documentation and try different parameters…
Good luck with your project! :)
March 10th, 2008 at 10:19 pm
I have a question? When you install the Thumbsnail Scroller component does in also installes the classes needed to code the thumbs scroller.
March 10th, 2008 at 11:23 pm
yes
March 29th, 2008 at 2:18 am
hi FlashOtaku,
really impressed with this components. i however have 2 problems. would be very much obliged to u if u could help me out on these .
1. the thumbnail scroller works well horizontally but when i change the paramaters to a vertical scroll the images just stack up on each other. am i doing somthing wrong?
2. For the big image slide is there anyway to add the left and right arrows for the big slide so that when these arrows are clicked it moves only the big pic slide? also if there is anyway i can put a counter that shows how many pics are there and what no. of pic is currently being viewed?
thanks a lot in advance :)
March 29th, 2008 at 10:32 am
Hi,
1. You just need to set the direction property to ‘vertical’ and then change the thumbnail scroller’s size (e.g. 100 X 500). Please see this working example
http://flashotaku.com/blog/yet-another-image-gallery
2. Use the nextImage() and prevImage() methods to go to the next and previous image. See this example http://flashotaku.com/blog/building-an-auto-slideshow-with-as3
You can show the index of the current slide.
example:
import com.flashotaku.slideshow.events.SlideshowEvent;
mySlideshow.addEventListener(SlideshowEvent.SLIDE_INIT, slideInitHandler);
function slideInitHandler(event:SlideshowEvent){
trace(event.slide.id);
}
To show the total number of images you would need to parse the XML file again. Make sure to check out the examples I’ve posted on the site.
March 31st, 2008 at 6:21 pm
thanks for the speedy reply. flashOtaku. will check out the examples u have listed :)
you rock :)
April 2nd, 2008 at 12:09 am
hi FlashOtaku,
sorry i am a bit too used to flash 8 and AS 2. so the flash site i made is in flash 8 and now when i use ur gallery with xml and title and discription gallery, it causes a problem as i am loading ur flash 9 gallery with a flash 8 flash. can u send me the scripting for ur gallery for flash 8 and scripting for the xml for the title and discription in AS2?
thanks a lot in advance.
April 2nd, 2008 at 12:49 pm
Hi,
I’ve posted the AS2 version in a comment at this post http://flashotaku.com/blog/yet-another-image-gallery since it is the AS2 version of that example
April 2nd, 2008 at 11:46 pm
wow flashOtaku,
thanks a lot for ur help. u really really rock!!! :)
April 2nd, 2008 at 11:54 pm
really wanted to thank u but could only donate a few $$ that was left in my paypal acc. hope it helps. and ya keep up the good work. looking forward to more outstanding work from u :)
April 3rd, 2008 at 10:35 am
Thank you for your contribution, ashen :)
April 15th, 2008 at 5:28 pm
Is there an easy way to change the pixel effect to a less busy blur, like in the other tutorials? I think it’s too distracting for my material
April 15th, 2008 at 6:28 pm
No, but you could try using “alpha” instead of “blur”.
April 24th, 2008 at 3:18 pm
Hey FlashOtaku,
I’m having a little trouble with the component. I am really new to flash, actionscript, and XML. So, I copied and pasted your code- I am starting to understand AS3 a bit, so I am able to adjust things to get them where I want them. But what I don’t get is the XML part. Do I have to load instances of XML? as of right now I have this to list my thumbnails:
-that’s all I have as far as XML might be concerned- I have swapped out image with the name of the jpg.
so any help you can give me as far as the XML goes would be greatly appreciated.
Lastly, I’m getting two errors now (both the same error for different components)
1151: a conflict exists with definition mySlideshow (and myScroller) in namespace internal.
The code where the errors are coming from is:
var mySlideshow:Slideshow = new Slideshow();
var myScroller:ThumbnailScroller = new ThumbnailScroller();
I know this is a lot, but thank you for any help you provide!
John
April 24th, 2008 at 4:16 pm
Hi John,
Concerning the XML part, you just need to create two XML files, one for the scroller and one for the slideshow, with the same format as in the files you’ve downloaded. After that, just give the slideshow and scroller the path to those XML files as in the example. For more info about the required format for the XML files see the documentation (here and here)
The error you’re getting is probably because you’ve dragged instances of the component to the stage and you’ve also declared those instances using ActionScript. You don’t need to do that. If you’ve used the code I’ve written in this tutorial, after you’ve dragged your components to the stage, delete them so that they will remain only in your library.
April 24th, 2008 at 6:34 pm
Thanks a lot for your input. I’m going to paste my code for the XML and if I’m way off just let me know and I’ll keep on messing with it!
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, showXML);
function showXML(e:Event):void {
XML.ignoreWhitespace = true;
var thumbnails:XML = new XML(e.target.data);
}
The other thing I was having trouble with is giving the slideshow and scroller the path- as of right now I have:
myScroller.xmlPath = “thumbnails.xml”;
Lastly, when I test the video, it says that the arrows are erroring out because they “call to a possibly undefined method.” Is that because I need to add the arrorws on to the stage?
Sorry I’m so needy when it comes to this, but never working with code before its like learning a new language! I indeed had an instance of the component on the stage- I’m very impress with your knowledge. I will keep studying in hopes of getting to the point where I don’t need help for such little things!
April 24th, 2008 at 7:13 pm
John, you don’t need to load the XML file; the component does that for you. All you have to do is create an XML file and name it, let’s say, “images.xml” and then give the slideshow the path to that XML file. The same for the scroller.
As for the error, it’s because you need an arrow in your library(not stage) that has an Arrow class associated with it. Bellow the demo you have links to the source file. You can download it and see exactly how it’s done.
Anyway, this a tutorial in which I use only code, without attaching anything to stage. If you’re new to Actionscript, this might seem a little complicated , so I recommend to check some other examples that use less Actionscript.
http://flashotaku.com/blog/image-gallery-tutorial-example-1
http://flashotaku.com/blog/roll-over-effect-for-the-thumbnailscroller
April 24th, 2008 at 8:21 pm
ok! The XML was really throwing me off because I have yet to work with it, but I’m glad I am learning. I have it all working except the correct path to the XML. My first guess was to upload it to my FTP site and give it that path and it didn’t work, and it didn’t allow my to import the XML documents to the library. I have them created, but I think my question is now where do the files need to be? In other words, where can flash read the XML file from? Do I leave it on my C drive? or is there a way to import it into the program? Thats the only thing I was struggling with. I was simply making it harder than it needed to be!
Thank you for all of your help, it is really appreciated.
John
April 24th, 2008 at 9:29 pm
The XML files can be anywhere; you just need to give the slideshow and scroller the correct path to these XML files. In this tutorial the XML files are in the same directory as the SWF, so the path to the XML file is simply the name of the XML. Let’s say your root folder is ‘gallery’. In this folder you have the FLA and SWF. If you create another folder inside the ‘gallery’, named ‘xmlfiles’, then the path to the XML file would be like this mySlideshow.xmlPath = “xmlfiles/images.xml”;
April 24th, 2008 at 9:58 pm
For whatever reason, it is telling me my path is not correct, but I know it is. Right now I have the xml files on the ftp site for my web page. They are not in a folder. the code i am giving it is:
myScroller.xmlPath = mywebpage.com/thumbnails.xml
mySlideshow.xmlPath = mywebpage.com/images.xml
I’ve tried various different ways to write the site name (ftp.mywebsite/images.xml, http://www.mywebsite/images.xml, http://www.mywebsite/images.xml) but none of them seem to be working. Sometimes I get a URL error, other times it says the path is wrong. I’m so close I can taste it!
April 24th, 2008 at 10:08 pm
ok, so I just went to the properties of the file and copied the location and it still didn’t work. Should I not be giving it a path through my FTP site?
April 24th, 2008 at 10:22 pm
If you’re getting an URL error, it means that the path to the XML file is now correct, but the path to each image, in the XML file, is not correct. Now you have to make sure the path to each image is correct too.
April 24th, 2008 at 11:27 pm
i’m getting an “error opening url….” “path of the xml file is not correct” error. I went back into the XML file and corrected the paths of the images themselves, but apparently it I’m not pointing it to the XML file correctly?
April 26th, 2008 at 2:44 pm
Hi FlashOtaku,
Ok, so At this point, the code is copied from your site and as far as the paths go, I have gone to the properties of each file and copied/pasted the path given in that file. I’ve uploaded the page, and the outline of the viewer shows up, and the arrows show up (at one point I was able to see the scroller on the arrows, but not since I’ve been trying things.) Any idea what the problem could be?
April 26th, 2008 at 2:53 pm
More information that may help, apparently, when you visit the page with the slideshow from a computer other than my own, it shows the page, but brings up a windows prompt to enter a username and password for the ftp site the files are on. Any ideas?
April 29th, 2008 at 11:09 am
Hi John,
There is not much I can say. You just have to write the correct paths. If you can’t figure out what the relative path is, use an absolute path.
April 30th, 2008 at 2:34 am
Hi FlashOtaku
I have just tried merging your pretty as3 sample file with my new art site. I have changed the images, and it works but it squashes my pictures. Is there a way to state in the actions layer from the sample file ‘Maintain aspect ratio’ or something similar. So the portrait and lanscape images remain the correct size? Sorry if this is a silly question, iam new to this.
Thanks
Also, thanks for putting me on to an awesome looking anime!
April 30th, 2008 at 8:43 am
Hi Zealboy,
To mantain the images’ aspect ratio use this code:
mySlideshow.scaleMode = “maintain aspect ratio” or you could use the component inspector. To use the component inspector click on the component and press Shift+F7. You will see a list of all available properties.
April 30th, 2008 at 11:17 am
Thank you! I put the code in, but i get a syntax error.
var mySlideshow:Slideshow = new Slideshow();
addChild(mySlideshow);
mySlideshow.xmlPath = “images.xml”;
mySlideshow.setSize(600, 600);
mySlideshow.x = 400;
mySlideshow.y = -50;
mySlideshow.setBorder = true;
mySlideshow.scaleMode = “maintain aspect ratio”
mySlideshow.borderThickness = 5;
mySlideshow.preloaderType = “circular”;
mySlideshow.transitionEffect = “squares”;
mySlideshow.squaresEffectType = “blur”;
mySlideshow.squaresDirection = “random”;
———————————————————-
Also – I have 4 pages/Menu buttons, on a buttons layer set to go to a seperate content layer on the 1,10,20,30 (Home,Gallery,About,Contact) frames
with this code for each button
homebtn.addEventListener(MouseEvent.CLICK, clickHome);
function clickHome(event:Event):void {
trace(“home”);
gotoAndStop(“Home”);
}
I have placed your sample code/ ActionScript layer on the 10th frame where my gallery begins. When i preview everything is fine, when i click on gallery it loads fine. But when i click on another menu button the Gallery stays there and will not disappear. Is there anyway to fix this?
Thank you for your time, patience and knowledge
April 30th, 2008 at 12:37 pm
If you are using frames, maybe it’s better not to instantiate your component using code, but instead just drag the component from the Components Window and drop it on the stage. Then, you can use the Component Inspector to set all the properties.
April 30th, 2008 at 12:46 pm
Thanks. I did it this way because i couldnt get the buttons to work.
June 2nd, 2008 at 12:35 pm
Hi FlashOtaku
First i got to say great job man, nice clean simple and professionally work.
But I got a problem!
I would like to get a description and a header for each picture (been working with Image Gallery Tutorial (Example 2)). like you have done with as3 earlier, but I would like to do it in as2 and only with code.
I´m stuck, have you got some ideas on how to do it?
thanks..
June 2nd, 2008 at 4:22 pm
Hi,
Here’s an example http://flashotaku.com/files/gallery_ex4_as2.zip
Hope it helps.
June 2nd, 2008 at 4:29 pm
Thanks a lot, will try it as soon as possible!
June 11th, 2008 at 4:57 pm
Hi FlashOatku,
Right now I am making a family website and am planning to use this code for a slideshow of all the family members.
I was wondering if there is a way to make the right and left arrows darker when the mouse hovers over them.
Thanks a lot.
June 11th, 2008 at 4:58 pm
Oh, I forgot to mention I am using Flash 8.
June 11th, 2008 at 9:04 pm
Hi Jeff,
You could use something like Tweener to animate the arrows.
import caurina.transitions.Tweener;left.onRollOver = right.onRollOver = function()
{
Tweener.addTween(this, {_color:0xFF0000, time:.3, transition:"linear"});
}
left.onRollOut = right.onRollOut = function()
{
Tweener.addTween(this, {_color:0xFFFFFF, time:.3, transition:"linear"});
}
June 11th, 2008 at 10:31 pm
Sweet! Thanks!
June 12th, 2008 at 2:32 am
Hi FlashOtaku,
I’m pretty new to AS3 and I’m having trouble with the smallest details… can you please help me?
I want to make it so that the full size images don’t show up until I click on one of the thumbnails, then once clicked, the border fades in and image animates in, what’s the easiest way to do this?
And how can I set a background fill for the image border so the images don’t just animate on top of other screens in the background?
Thanks so much in advance…
Zanchy
June 12th, 2008 at 2:35 am
Oh and BTW FlashOtaku, this is the best image gallery for AS3 that I have found so far, and believe me, I have been looking hard…
Very professional, and organized so that even I can understand ;-D
(I got so caught up in my question I forgot to include my excitement over this awesome tutorial! – Thanks!)
June 12th, 2008 at 11:59 am
Hi Zanchy,
I’ve made a simple example that shows how to make the slideshow appear only after a thumbnail is selected. You can also see how to make the border fade in.
http://flashotaku.com/files/gallery_ex5_as3.zip
hope it helps.
As for the background fill, you could just draw a rectangle and position it under the slideshow.
June 12th, 2008 at 10:41 pm
Hey FlashOtaku,
Thanks for the quick reply but sadly the link you’ve provided is not working.
I tried some codes myself but I get a wierd outcome after the image is loaded..
i added
mySlideshow.visible = false;
mySlideshow.enabled = false;
and also added a counter true command when clicked but as it loads the new image, there are remnants of the old image behind it which makes it look ugly…
I guess the easiest thing for me to do would be to include a blank image as part of my library.
Anyways, thanks for your help..
Zanchy
June 13th, 2008 at 7:53 am
Sorry about the link…I’ve corrected it now.
http://flashotaku.com/files/gallery_ex5_as3.zip
June 17th, 2008 at 7:36 pm
Hi FlashOtaku,
Nice job man, very useful and flexible.
I wonder to know if it is possible to add some more features.
1. XML Header(expandable) + XML Full Story
When you bring mouse over the “Header” so it will Expand up and down, loading “Full Story”, same time the slideshow will pause .
2.Auto Slideshow and changing thumbs for example up and down synchronized
3.How to make that each thumb to have its XML title?
Thanks so much in advance :)
June 18th, 2008 at 1:00 pm
Hi Terast,
Here are some examples in which I think you can find answers to your questions:
http://flashotaku.com/blog/yet-another-image-gallery/
http://flashotaku.com/files/gallery_ex5_as3.zip
June 20th, 2008 at 8:33 am
Nice job..
I am really grateful for the wonderful work you are doing. I have used this gallery a lot of times but is there a way to use page buttons instead of the thumbnails. I know this is possible but I just dont know how to go about it. Would also like it to auto play and lopp when the last image is reached but at the same time be able to control it with the buttons..
I hope you can help, thanks a million
July 2nd, 2008 at 10:15 am
Nice job, man!!!
I jus wonder how can i embed the file into my page? I’ve already have the folder in the same directory of my page but seem the flash doesnt work. Is there any trick that I dont kno about???
July 2nd, 2008 at 10:45 am
can i change the background color??? I cannot open the file ‘gallery.fla’ for editing. It gave an error of ‘file format unexpected’.
what can i do to change the background color???
July 2nd, 2008 at 1:42 pm
Hi,
If you’re using Flash 8, please download the Actionscript 2 version of the file.
July 2nd, 2008 at 5:41 pm
hi how do i make it load random images and also make the thumbs loop infinite instead of getting stuck in the last one,i want it to repeat the first thumb again over an over
July 3rd, 2008 at 12:28 pm
Hi,
See this example for loading random images: http://flashotaku.com/files/slideshow_rnd_as3.zip
As for infinite loop, it can’t be done with this component.
July 3rd, 2008 at 7:07 pm
Hi FlashOtaku,
Great work on the components!
I have two questions regarding the as2 versions of the slideshow and thumbnailscroller
1. Is there a way to load a .php file rather than a .xml xmlFile.load(“images.php”);
Instead of
xmlFile.load(“images.xml”);
I have a created a .php file which outputs the xml as it would appear in a .xml document, but it doesn’t load when the file extension is .php
2. How can I highlight and/or scroll to the corresponding thumbnail for the loaded image in the Slideshow (while in autoplay mode or not).
July 3rd, 2008 at 7:50 pm
Ok, I’ve managed to resolve question 1 on my own and now I can use a .php file for my xml content
.
For those who are interested, please be sure to specify the header in your php script before outputting any xml content so that the server knows to handle requests for your php file as xml.
eg. header (“content-type: text/xml”);
Then you can echo the rest of your xml content as required.
As for my second question (..highlight and/or scroll to corresponding thumbnail for the loaded image in the Slideshow…), I yet to find a way to achieve this so any help is greatly appreciated.
July 4th, 2008 at 1:12 pm
Hi AlleyKat,
Glad you’ve found a solution to your first question. About the second question, here’s an AS3 example http://flashotaku.com/files/gallery_ex6_as3.zip. See if you can translate that to AS2. If not, I’ll make an AS2 example later.
July 4th, 2008 at 1:43 pm
Thank you for your fast response!
Unfortunately I am using Flash 8 and cannot load the example so an AS2 version would be a great help.
July 4th, 2008 at 5:54 pm
Here’s the AS2 version:
http://flashotaku.com/files/gallery_ex6_as2.zip
July 18th, 2008 at 1:45 pm
Hi there,
This slideshow component is great !. I am having one difficulty though, When I use a proxy url for image in xml, flash freezes for sometime and then loads the pic. Example -
Thanks
July 18th, 2008 at 3:36 pm
Hi Abdul,
I would like to see the example you’re talking about, if you can post a link.
July 18th, 2008 at 8:38 pm
Hi,
Can some one help me make the slideshow, title, and description invisible till a thumnail is clicked. And an option to close the slideshow.. when done viewing?
July 20th, 2008 at 12:48 am
Hi FlashOtaku,
It seems the preloader ( i had circular ) was having difficulty, and was timing out at 15 seconds, so I disabled the preloader, and it seems to be working fine ( as a workaround )
This happend only while using proxy url for image.
Thanks
-Abdul
July 21st, 2008 at 1:51 pm
@Nathan
Here’s an example on how to make the slideshow appear only after a thumbnail is clicked: http://flashotaku.com/files/gallery_ex5_as3.zip. To close the slideshow, you could simply remove it from the display list (mySlideshow.parent.removeChild(mySlideshow))
@Abdul
Glad you’ve worked it out.
July 22nd, 2008 at 6:26 pm
Thank you so much FlashOtaku for the example file you posted regarding the syncronizing the thumbnails to the slideshow. I have finally managed to implement it now but I am getting some weird behaviour with the slide show now.. not sure what I’ve done wrong but every other slide in the slide show now appears rotated by 180 degrees and the alignment also appears to be left in those instances rather then center. Any ideas what I could be wrong to cause this?
July 22nd, 2008 at 6:33 pm
I’ve mistated the degrees in my last post.. irratically, every other slide is being rotated by 90 degrees. I’m suspecting some sort of conflict with the slideshow component parameters and the as2 defined parameters.. Any ideas on how I can fix this would be greatly appreciated.
July 22nd, 2008 at 7:01 pm
Update: I beleive I may have found a bug in the as2 slideshow component, or something went wrong while I was installing this component. I the component’s parameters I have found a double entry for “text preloader font size”. This first entry provides a dropdown option for true or false and the second entry merely has a text field to enter the font size (I’ve set these as “false” and “12″ respectively). I suspect that the first entry is where the problem lies.. FlashOtaku can you please confirm this for me.
July 23rd, 2008 at 1:58 pm
Hi AlleyKat,
About the two “text preloader font size” entries, the true/false one is for making the text bold, so it should be “text preloader font bold”. That’s my bad.
As for the slides being rotated, that’s strange because the slides are never rotated in the component’s code. If you can post your code I will take a look at it.
July 23rd, 2008 at 10:47 pm
Thanks for letting me know about the text preloader thing..
As for the rotating problem.. it’s really irratic.. sometimes when I create the swf file it will be fine and sometimes it does this rotating thing.. Something else I’ve noticed is that the autoscrolling and highlighting (yellow bordering) of the thumbs to sync with the slideshow doesn’t always slide back to the first thumb when the scrolling reaches the last thumb in the list but the highlighting remains consistent.
Here’s the code..
import caurina.transitions.Tweener;
var releaseObj:Object = new Object();
var titleArray:Array = new Array();
var descriptionArray:Array = new Array();
var xmlFile:XML = new XML();
var level = this;
var slideInitObj:Object = new Object();
var thumbInitObj:Object = new Object();
var transitionCompleteObj:Object = new Object();
var allThumbsObject:Object = new Object();
var initObj:Object = new Object();
var rollOverObj:Object = new Object();
var rollOutObj:Object = new Object();
var onSlideComplete:Object = new Object();
var Panolink = “http://www.somedomain.com/pano.php?tourid=”+tourid;
var panoslink_y:Number = 383.3;
var selectedThumb:Object;
var thumbnails:Array = new Array();
var totalThumbs:Number = 0;
var interval:Number;
var stopshow:Number = 2;
mySlideshow.xmlPath = “http://www.somedomain.com/images_xml.php?tourid=”+tourid;
myScroller.xmlPath = “http://www.somedomain.com/images_xml.php?tourid=”+tourid;
myScroller._alpha = 0;
downArrow._visible = false;
upArrow._visible = false;
panos_link._visible = false;
mySlideshow._visible = false;
myTitle._visible = false;
top_bar._visible = false;
slideshowBack_btn._visible = false;
slideshowNext_btn._visible = false;
fullscreen_mc._visible = false;
pause_btn._visible = false;
play_btn._visible = false;
panos_link._visible = false;
myDescription._visible = false;
bottom_bar._visible = false;
if (haspanos != “”) {
panoslink_y = 383.3;
} else {
panoslink_y = 483.3;
}
myScroller.addEventListener(“onThumbInit”, thumbInitObj);
mySlideshow.addEventListener(“transitionComplete”, transitionCompleteObj);
myScroller.addEventListener(“rollOver”, rollOverObj);
myScroller.addEventListener(“rollOut”, rollOutObj);
myScroller.addEventListener(“release”, releaseObj);
myScroller.addEventListener(“allThumbsAdded”, allThumbsObject);
mySlideshow.addEventListener(“onSlideComplete”, onSlideCompleteObject);
mySlideshow.addEventListener(“onSlideInit”, slideInitObj);
mySlideshow.xmlPath = “http://www.somedomain.com/images_xml.php?tourid=”+tourid+”&”;
xmlFile.load(“http://www.somedomain.com/images_xml.php?tourid=”+tourid+”&”);
xmlFile.ignoreWhite = true;
xmlFile.onLoad = function(succes:Boolean){
if(succes){
for(var i=0; i<this.firstChild.childNodes.length; i++){
if(this.firstChild.childNodes[i].attributes.title != undefined){
level.titleArray.push(this.firstChild.childNodes[i].attributes.title);
}
if(this.firstChild.childNodes[i].attributes.description != undefined){
level.descriptionArray.push(this.firstChild.childNodes[i].attributes.description);
}
}
}
}
thumbInitObj.onThumbInit = function(event:Object)
{
Tweener.addTween(event.target.child, {_alpha:85, time:.1, transition:”linear”});
thumbnails.push(event.target);
totalThumbs++;
}
transitionCompleteObj.transitionComplete = function(event:Object)
{
if (stopshow == 1) {
interval = setInterval(intervalHandler, 5500, event.target.id);
}
else {
clearInterval(interval);
}
}
rollOverObj.rollOver = function(event:Object){
Tweener.addTween(event.target.child, {_alpha:100, time:.1, transition:”linear”});
}
rollOutObj.rollOut = function(event:Object){
Tweener.addTween(event.target.child, {_alpha:85, time:.1, transition:”linear”});
}
releaseObj.release = function(event:Object){
mySlideshow.loadImage(event.target.id);
highlightBorder(event.target);
clearInterval(interval);
}
allThumbsObject.allThumbsAdded = function(event:Object) {
MyPreloader._visible = false;
myScroller._alpha = 100;
downArrow._visible = true;
upArrow._visible = true;
panos_link._visible = true;
mySlideshow._visible = true;
myTitle._visible = true;
top_bar._visible = true;
slideshowBack_btn._visible = true;
slideshowNext_btn._visible = true;
fullscreen_mc._visible = true;
pause_btn._visible = true;
play_btn._visible = true;
panos_link._visible = true;
myDescription._visible = true;
bottom_bar._visible = true;
stopshow = 1;
interval = setInterval(intervalHandler, 5500, event.target.id);
}
panos_link._y = panoslink_y;
bottom_bar.onRollOver = function(){
bottom_bar.useHandCursor = false;
}
top_bar.onRollOver = function(){
top_bar.useHandCursor = false;
}
slideshowNext_btn.onRollOver = function() {
slideshowBack_btn._alpha = 30;
slideshowNext_btn._alpha = 80;
}
slideshowNext_btn.onRollOut = function() {
slideshowBack_btn._alpha = 30;
slideshowNext_btn._alpha = 30;
}
slideshowNext_btn.onRelease = function() {
mySlideshow.nextImage();
if (id == totalThumbs-1)
{
myScroller.moveAmount = totalThumbs * (myScroller.space + myScroller.thumbWidth);
myScroller.moveLeft();
}
else
{
myScroller.moveAmount = myScroller.space + myScroller.thumbWidth;
myScroller.moveRight();
}
}
slideshowBack_btn.onRelease = function() {
mySlideshow.prevImage();
if (id == totalThumbs-1)
{
myScroller.moveAmount = totalThumbs * (myScroller.space + myScroller.thumbWidth);
myScroller.moveLeft();
}
else
{
myScroller.moveAmount = myScroller.space + myScroller.thumbWidth;
myScroller.moveLeft();
}
}
slideshowBack_btn.onRollOver= function() {
slideshowBack_btn._alpha = 80;
slideshowNext_btn._alpha = 30;
}
slideshowBack_btn.onRollOut = function() {
slideshowBack_btn._alpha = 30;
slideshowNext_btn._alpha = 30;
}
downArrow.onRelease = function(){
myScroller.moveLeft();
}
upArrow.onRelease = function(){
myScroller.moveRight();
}
downArrow.onRollOver = function(){
downArrow._alpha = 80;
}
downArrow.onRollOut = function(){
downArrow._alpha = 46;
}
next_btn.onRelease = function(){
myScroller.moveRight();
}
upArrow.onRollOver = function(){
upArrow._alpha = 80;
}
upArrow.onRollOut = function(){
upArrow._alpha = 46;
}
back_btn.onRelease = function(){
myScroller.moveLeft();
}
pause_btn.onRelease = function(){
clearInterval(interval);
pause_btn._visible = false;
play_btn._visible = true;
stopshow = 2;
}
play_btn.onRelease = function(){
interval = setInterval(intervalHandler, 5500, event.target.id);
mySlideshow.nextImage();
play_btn._visible = false;
pause_btn._visible = true;
stopshow = 1;
}
panos_link.onRollOver = function() {
panos_link._alpha = 100;
}
panos_link.onRollOut = function() {
panos_link._alpha = 90;
}
onSlideCompleteObject.onSlideComplete = function(event:Object) {
LoadingTourtext._visible = false;
mySlideshow._alpha = 100;
top_bar._alpha = 40;
slideshowBack_btn._alpha = 30;
slideshowNext_btn._alpha = 30;
bottom_bar._alpha = 40;
myDescription._alpha = 90;
fullscreen_mc._alpha = 90;
pause_btn._alpha = 100;
}
LoadingTourtext._visible = true;
slideInitObj.onSlideInit = function(event:Object){
Tweener.addTween(myTitle, {alpha:0, _blur_blurX:20, _blur_quality:2, time:.5, transition:”linear”, onComplete:showText, onCompleteParams:[event.target.id]});
Tweener.addTween(myDescription, {alpha:0, _blur_blurX:20, _blur_quality:2, time:.5, transition:”linear”});
highlightBorder(thumbnails[event.target.id]);
}
function showText(nr){
myTitle.text = titleArray[nr];
myDescription.text = descriptionArray[nr];
Tweener.addTween(myTitle, {alpha:100, _blur_blurX:0, _blur_quality:2, time:.3, transition:”linear”});
Tweener.addTween(myDescription, {alpha:100, _blur_blurX:0, _blur_quality:2, time:.3, transition:”linear”});
}
function highlightBorder(thumb:Object)
{
if(selectedThumb)
{
Tweener.addTween(selectedThumb.border, {_color:0×666666, time:.1, transition:”linear”});
}
selectedThumb = thumb;
Tweener.addTween(selectedThumb.border, {_color:0xFFCC00, time:.1, transition:”linear”});
}
function intervalHandler(id:Number)
{
if (stopshow == 1) {
clearInterval(interval);
mySlideshow.nextImage();
if (id == totalThumbs-1)
{
myScroller.moveAmount = totalThumbs * (myScroller.space + myScroller.thumbWidth);
myScroller.moveLeft();
}
else
{
myScroller.moveAmount = myScroller.space + myScroller.thumbWidth;
myScroller.moveRight();
}
}
else
{
clearInterval(interval);
}
}
fullscreen_mc.onRollOver = function() {
fullscreen_mc._alpha = 100;
}
fullscreen_mc.onRollOut = function() {
fullscreen_mc._alpha = 90;
}
fullscreen_mc.onRelease = function() {
if (Stage["displayState"] == “normal”)
{
goFullScreen(stage.displayState);
myDescription._visible = false;
bottom_bar._visible = false;
panos_link._visible = false;
upArrow._visible = false;
downArrow._visible = false;
panos_link._y = 483.3;
upArrow._y = 479.5;
downArrow._y = 479.5;
myScroller._alpha = 0;
myScroller._y = 475;
mySlideshow.setSize(598, 415);
myTitle._y = 18.8;
myTitle._x = 5.8;
play_btn._y = 18.3;
pause_btn._y = 17.7;
play_btn._x = 478;
pause_btn._x = 477.6;
fullscreen_mc._y = 19.5;
fullscreen_mc._x = 507;
top_bar._height = 25.8;
top_bar._width = 594;
top_bar._y = 14.3;
top_bar._x = 2;
mySlideshow._x = 0;
mySlideshow._y = 5.2;
}
else if (Stage["displayState"] == “fullScreen”)
{
myDescription._visible = true;
bottom_bar._visible = true;
panos_link._visible = true;
upArrow._visible = true;
downArrow._visible = true;
panos_link._y = panoslink_y;
upArrow._y = 379.5;
downArrow._y = 379.5;
myScroller._y = 375;
myScroller._alpha = 100;
mySlideshow.setSize(555.2,363.1 );
mySlideshow._x = 20;
mySlideshow._y = 5.2;
myTitle._y = 11.8;
myTitle._x = 32.8;
play_btn._y = 9.7;
pause_btn._y = 9.7;
play_btn._x = 441.6;
pause_btn._x = 441.6;
fullscreen_mc._y = 11.5;
fullscreen_mc._x = 477;
top_bar._height = 25.8;
top_bar._width = 539.5;
top_bar._y = 7.3;
top_bar._x = 28.1;
exitFullScreen(stage.displayState);
}
}
function goFullScreen(){
Stage["displayState"] = “fullScreen”;
}
function exitFullScreen(){
Stage["displayState"] = “normal”;
}
panos_link.onRelease = function(){
getURL((Panolink), “_self”);
}
July 24th, 2008 at 12:28 pm
I can’t see anything in the code that would rotate the slides. I suggest you try using some local XML files and images to see if it works OK that way. If it does, it could be a cross domain policy issue.
July 28th, 2008 at 2:34 am
Hi Flashotaku..
This is just a follow up on that weird issue of the radom rotating of the slides. I’ve checked the cross domain policy and it doesn’t seem to be an issue. What I am suspecting now is latency in loading of the xml file. I’m wondering if it may be better to load the listeners within the load xml success statement so that only upon success the listeners will be initialized. Do you think that if the xml file is not fully loaded and the listeners have already started would cause this sort of problem?.. I have noticed that if I refresh the page (sometimes it takes a few times) the rotation issue goes away. Any thoughts?
July 28th, 2008 at 8:43 am
Here’s a little more to report on the rotations issue..
I have noticed that if the images load improperly (rotated 90 degrees), then upon clicking the matching thumbnail the image will be loaded correctly and then the following image in the slideshow will appear rotated. Otherwise, it appears that every other image is rotated throughout the show.
July 29th, 2008 at 10:11 am
You could also try attaching the slideshow using AS:
this.attachMovie(“Slideshow”, “mySlideshow”, this.getNextHighestDepth());
See if it works this way.
July 29th, 2008 at 2:04 pm
I will try that and let you know.. I tried setting the autoload to false and that appears to stop the rotating problem but it appears that the actual problem is elsewhere. When I check the value of event.target.id for each slide as it plays, I noticed that the first slide sometimes return a value of undefined and other times returns a value of zero (which would be the correct value). How can I either, reload the slideshow until it returns the proper array id (zero) for the first slide, or ensure that everthing is loaded properly before proceeding with the rest of the AS code?
July 29th, 2008 at 3:17 pm
You can set the autoLoad to false and listen for the onLoadXML event, and after the XML file was loaded you can load the first image mySlideshow.loadImage(0);
mySlideshow.xmlPath = “images.xml”;
mySlideshow.autoLoad = false;
var loadXMLObj:Object = new Object();
loadXMLObj.onLoadXML = function(event:Object)
{
mySlideshow.loadImage(0);
}
mySlideshow.addEventListener(“onLoadXML”, loadXMLObj);
July 29th, 2008 at 3:37 pm
Thank you, let me try that.. btw, I was looking at the rest of my AS code and I wondering if I should be calling all the event listeners last as you have in your example above. Currently I call all my event listeners right after declaring all my vars at the top of my code. Do you think this has any impact or is it just good coding practices?
July 29th, 2008 at 5:02 pm
All you need to consider when adding an event listener is adding it before the event will be dispatched. Other than that is just preferences IMO.
July 30th, 2008 at 11:46 am
hi FlashOtaku,
is it possible to make continuous scrolling in your thumbnails?…
thanks ahead….
rynzco
July 30th, 2008 at 1:31 pm
Hi rynzco,
I’m not sure if it’s what you’re looking for but see this example http://flashotaku.com/files/gallery_ex6_as3.zip
July 31st, 2008 at 6:01 am
Hi flashOtaku,
not exactly, i mean its more likely(http://www.toddlajoie.com/gtal/tutorials/samples/array_scrolling.html)..is it possible?…
BTW thanks for your quick reply,
you’re so cool man….
cheers
rynzco
July 31st, 2008 at 10:22 am
Unfortunately, that is not possible with this scroller component.
Cheers
August 12th, 2008 at 2:17 am
hi otaku im new on this thing of xml, your work its greate i just want to know if theres a way when you mouse over the thumbnails appears a simple mouse handler like when you have i mouse button,
thank you for your time,
regards
August 12th, 2008 at 12:14 pm
Hi,
Add this code:
myScroller.addEventListener(ThumbnailEvent.THUMB_INIT, thumbInitHandler);
function thumbInitHandler(event:ThumbnailEvent)
{
event.item.bottonMode = true;
}
August 18th, 2008 at 10:54 am
I’ve noticed that when using the alpha transition there is quite a bit of flicker going on & it’s not very smooth. It doesn’t help when increasing the fps in the player either. How are the transitions handled, with a tweening engine?
Niklas
August 18th, 2008 at 6:34 pm
Hi!
This slideshow is Super! As you’ve been so generous to help others, I was hoping you wouldn’t mind throwing a little more of your expertise my way…I’d like to add dynamic image titles. I think I can handle the code in the xml but I don’t trust myself with the actionscript.
Thanks!
August 18th, 2008 at 6:40 pm
The fade transition is done with a simple Timer. However, a value of 30 for the transitionSpeed parameter would smooth the transition prety well.
August 18th, 2008 at 7:33 pm
Hi Kladdagh64,
Do you mean something like this http://flashotaku.com/blog/yet-another-image-gallery ?
August 19th, 2008 at 8:44 pm
Yes, something like that. I downloaded the source but the 2 slideshows are set up differently and I’m just not sure how/where to add the code. Your help is GREATLY appreciated!
August 19th, 2008 at 9:30 pm
Please give me more a more detailed description of what you’re trying to make.
August 21st, 2008 at 3:43 pm
I actually figured it out myself, based on “yet-another-image-gallery ” Thanks so much!
October 3rd, 2008 at 3:50 pm
hello everyone,
very nice component. how can we replace image to video (.flv). is it possible?
October 3rd, 2008 at 4:51 pm
Theoretically, you could place your FLVs inside some SWF files and then load the SWF files but it’s not working well so I don’t recommend using FLVs with this component.
October 4th, 2008 at 1:26 am
hello,
could it be possible to add title on the right side when choosing vertical scroller and add some event when rollover and click of the thumbnail. It scale a little the thumbnail when rollover including the title on the right side. is it possible? thanks.
October 4th, 2008 at 3:02 pm
Hi,
See this similar example http://flashotaku.com/files/scroller_text_as3.zip about adding title.
As for scaling the thumbnail that wouldn’t work so well. Roll over effects that change the size or position of the thumbnails are not recommended.
October 5th, 2008 at 7:08 am
nice scroller text sample but my pc hang-up when publishing the source fla. what i want to make the scrollbar thumbnail effect is by referring this url. http://www.501.com/en_IN/index.html#media.
thanks.
October 6th, 2008 at 3:52 am
hello,
do you have a sample scroller to simulate the scrollbar at this url http://www.501.com/en_IN/index.html#media? it scale in/out and the title as well and activate the thumb when click. thanks thanks…
October 6th, 2008 at 11:28 am
Hi rex,
As I said, effects that change the change the dimension or position of the thumbnails don’t work well. The effects that do work are those that change the thumbnail’s alpha, blur, rightness etc.
October 22nd, 2008 at 6:51 pm
Sorry if this is obvious, but how do I set smoothing on the slide images? Mainly looking for the target path here.
Thanks,
Robin
October 23rd, 2008 at 3:49 pm
Hi Robin,
The images can’t be smoothened.
October 23rd, 2008 at 6:36 pm
Err, how come? Just no function for it built into the component?
October 24th, 2008 at 2:27 pm
OK, I’ve added the feature. You can set the smoothing from the Component Inspector or using code (mySlideshow.smoothing = true). You need to re-download and re-install the component.
October 30th, 2008 at 11:40 pm
Hello FlashOtaku, your gallery is a life saver as I want to change my flash site from AS 2.0 to AS 3.0, but whenever I Test Movie i get this error: Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found. from the output window, not the compiler window. Only my 1st thumb and 1st pic from both xml files load. I cannot find where it is coming from. I even just used you example and changed the paths in the xml to some thumbs and pics I have.
October 30th, 2008 at 11:46 pm
IIIIIIII figured it out, sorry lol. The path to one of the files in my xml was incorrect :-D
November 3rd, 2008 at 8:36 pm
FlashOtaku,
I would like to know how you can make components in Flash CS3. Thanks.
November 4th, 2008 at 10:49 pm
Hy ScottyB,
Please be more specific. Building a component requires several steps. What exactly do you want to know?
November 5th, 2008 at 2:51 pm
I would like to know some (if not most) of the scripting for the slideshow component and/or thumbnailscroller because I am trying to make a portfolio that uses a XML image gallery for myself. There are traces of your components I would like to tweek to figure out the coding and reverse engineer to better understand AS3. I completely understand if you do not want to hand out this information since the coding is your work. Thanks for replying.
November 5th, 2008 at 7:45 pm
Well, there are some reasons why I don’t want to release the source.
However, if you have any specific question, about how to do certain things, I will answer you.
November 6th, 2008 at 6:01 pm
FlashOtaku,
Thanks for the reply, and like what I said before I completely understand why you don’t want to release this kind of information out. As of right now, I have no further questions to ask. Keep up the good work and you create some excellent components. Thanks again for the replies.
ScottyB.
January 25th, 2009 at 5:07 am
hi,
how do i put a gradient in back of the thumbnails
January 26th, 2009 at 1:02 pm
What do you mean, exactly?
March 2nd, 2009 at 4:50 pm
FlashOtaku,
First off, I love the layout of this image gallery and am looking to implement it into a new site I am building.
My problem is that the Slideshow and thumbnail scroller still appear on the frames that do not have the code attached to that frame (I am using 2 scenes, one for the main page and one for the image galleries/slideshows and the slideshow and thumbnail scroller appear on the frames of the main scene).
What code do I need to add to the other frames to prevent this from happening?
Thanks in advance,
Josh
March 4th, 2009 at 1:43 pm
Hi Josh,
Try making the component invisible on those frames.
First give the component an instance name: mySlideshow, for example and then add mySlideshow.visible = false when you want to hide the component and mySlideshow.visible = true when you want to show it.
May 1st, 2009 at 6:38 pm
Hi I am sorry for the multiple posts but I need your help. I have the slide show and I need it to reset everytime it gets to the end of the data and look for updated XML
Can you help?
June 16th, 2009 at 3:08 pm
Is it possible to load the images in from an asp file built with the same structure as the xml within parameters?
June 16th, 2009 at 9:25 pm
You can only use an XML file but you can dynamically generate that XML file using ASP.