ThumbnailScroller Component AS3 Documentation
Actionscript 3, Documentation, Flash Components December 20th, 2007Here is the documentation for the ThumbnailScroller Component AS3. I hope you will find it easy to use. If you have any questions, feel free to ask.
To preview and download the component go here.
Requirements
Authoring: Flash CS3
Actionscript: Actionscript 3 (Actionscript 2 version available here)
Player: Flash Player 9
Methods
moveRight()
moveLeft()
moveUp()
moveDown()
example:
-
import flash.events.MouseEvent;
-
-
left.addEventListener(MouseEvent.MOUSE_DOWN, leftHandler);
-
right.addEventListener(MouseEvent.MOUSE_DOWN, rightHandler);
-
-
function leftHandler(event:MouseEvent){
-
myScroller.moveLeft();
-
}
-
-
function rightHandler(event:MouseEvent){
-
myScroller.moveRight();
-
}
cMoveRight()
cMoveLeft()
cMoveUp()
cMoveDown()
cMoveStop()
example:
-
import flash.events.MouseEvent;
-
-
left.addEventListener(MouseEvent.ROLL_OVER, cLeftHandler);
-
right.addEventListener(MouseEvent.ROLL_OVER, cRightHandler);
-
left.addEventListener(MouseEvent.ROLL_OUT, cStopHandler);
-
right.addEventListener(MouseEvent.ROLL_OUT, cStopHandler);
-
-
function cLeftHandler(event:MouseEvent){
-
myT.cMoveLeft();
-
}
-
function cRightHandler(event:MouseEvent){
-
myT.cMoveRight();
-
}
-
function cStopHandler(event:MouseEvent){
-
myT.cMoveStop();
-
}
setSize(w:Number, h:Number)
example: myScroller.setSize(500, 70);
Properties
xmlPath
- type:String
- the path to the xml file
example: myScroller.xmlPath = “images.xml”;
thumbHeight
-type:Number
-default value: 70
example: myScroller.thumbHeight = 70;
thumbWidth
-type:Number
-default value: 100
example: myScroller.thumbWidth = 100;
scaleMode
- type:String
- available values: “exact fit”, “maintain aspect ratio”
- default value: “exact fit”
example: myScroller.scaleMode = “maintain aspect ratio”;
alignType
- type:String
- available values: “top”, “bottom”, “center”, “left”, “right” (you use “top” or”bottom” only when the direction is horizontal and “left” or “right” only when the direction is vertical)
- default value: “center”
example: myScroller.alignType = “bottom”;
direction
- type:String
- default value: “horizontal”
example: myScroller.direction = “vertical”;
space
-type:Number
-defaultValue: 10
example: myScroller.space = 5;
mouseMove
-type:Boolean
-default value: false
-if true, the images are scrolling when you move the mouse over the component
example: myScroller.mouseMove = true;
moveAmount
-type:Number
-default value: 100
-important only when you use the methods: moveRight(), moveLeft(), moveUp() and moveDown()
example: myScroller.moveAmount = 200;
duration
-type:Number
-default value: 1
-important only when you use the methods: moveRight(), moveLeft(), moveUp() and moveDown()
example: myScroller.duration = 2;
easingType
- type:String
- available values: “Back”, “Bounce”, “Circular”, “Cubic”, “Elastic”, “Exponential”, “Linear”, “Quadratic”, “Quartic”, “Quintic”, “Sine”
- default value: “Exponential”
-important only when you use the methods: moveRight(), moveLeft(), moveUp() and moveDown()
example: myScroller.easingType = “Quadratic”;
easingMethod
- type:String
- available values: “easeIn”, “easeOut”, “easeInOut”, “easeOutIn”
- default value: “easeOut”
-important only when you use the methods: moveRight(), moveLeft(), moveUp() and moveDown()
example: myScroller.easingMethod = “easeInOut”;
speed
-type:Number
-default value: 10
-the speed of the scrolling, in frames; a lower value for the speed propertie means a higher speed and vice versa
-important only when you use the methods: cMoveRight(), cMoveLeft(), cMoveUp(), cMoveDown() or when the mouseMove propertie is set to true
setBorder
- type:Boolean
- default value: false
example: myScroller.setBorder = true;
borderThickness
- type:Number
- default value: 2
example: myScroller.borderThickness = 3;
borderAlpha
- type:Number
- default value: 100
example: myScroller.borderAlpha = 50;
borderColor
- type:Number
- default value: #ffffff
example: myScroller.borderColor = 0×33ffcc;
preloaderType
- type:String
- available values: “bar”, “circular”, “none”
- default value: “bar”
example: myScroller.preloaderType = “circular”;
barPreloaderWidth
- type:Number
- default Value: 80
example:myScroller.barPreloaderWidth = 50;
circularPreloaderRadius
- type:Number
- default Value: 10
example:myScroller.circularPreloaderRadius = 15;
preloaderFillColor
- type:Number
- default value: #ffffff
example: myScroller.preloaderFillColor = 0×33ff00;
preloaderLineColor
- type:Number
- default value: #ffffff
example: myScroller.preloaderLineColor = 0×33cc33;
preloaderFillAlpha
- type:Number
- default value: 50
example: myScroller.preloaderFillAlpha = 40;
preloaderLineAlpha
- type:Number
- default value: 100
example: myScroller.preloaderLineAlpha = 80;
setTextPreloader
- type:Boolean
- default value: true
example: myScroller.setTextPreloader = false;
textPreloaderFont
- type:String
- default value: “Arial”
example: myScroller.textPreloaderFont = “Verdana”;
textPreloaderSize
- type:Number
- default value: 12
example: myScroller.textPreloaderSize = 10;
textPreloaderColor
- type:Number
- default value: #ffffff
example: myScroller.textPreloaderColor = 0×33ff00;
textPreloaderBold
- type:Boolean
- default value: false
example: myScroller.textPreloaderBold = true;
Working with XML
The “path” attribute is used to tell the component the path to each image.
example:
-
<thumbnails>
-
<image path="thumbnails/image0.jpg" />
-
<image path="thumbnails/image1.jpg" />
-
<image path="thumbnails/image2.jpg" />
-
<image path="thumbnails/image3.jpg" />
-
<image path="thumbnails/image4.jpg" />
-
<image path="thumbnails/image5.jpg" />
-
<image path="thumbnails/image6.jpg" />
-
<image path="thumbnails/image7.jpg" />
-
<image path="thumbnails/image8.jpg" />
-
<image path="thumbnails/image9.jpg" />
-
</thumbnails>
Working with events
XML_OPEN
- dispatched when the loading of the XML file starts
XML_PROGRESS
- dispatched when the XML file is loading
XML_COMPLETE
- dispatched when the loading of the XML file is complete
THUMB_OPEN
- dispatched when the loading of a thumbnail starts
THUMB_PROGRESS
- dispatched when a thumbnail is loading
THUMB_INIT
- dispatched when the properties of a thumbnail are available
THUMB_COMPLETE
- dispatched when the loading of a thumbnail is complete
ALL_THUMBS_ADDED
- dispatched when all the thumbnails are loaded
CLICK
- dispatched when the user is clicking on a thumbnail
ROLL_OVER
- dispatched when the user moves the mouse over a thumbnail
ROLL_OUT
- dispatched when the user moves the mouse away from a thumbnail
MOUSE_UP
- dispatched when the user releases the mouse over a thumbnail
MOUSE_DOWN
- dispatched when the user presses the mouse over a thumbnail
MOUSE_OVER
- dispatched when the user moves the mouse over a thumbnail
MOUSE_OUT
- dispatched when the user moves the mouse away from the thumbnail
example:
-
import com.flashotaku.thumbnailscroller.events.ThumbnailEvent;
-
-
myScroller.addEventListener(ThumbnailEvent.THUMB_PROGRESS, thumbProgressHandler);
-
myScroller.addEventListener(ThumbnailEvent.ALL_THUMBS_ADDED, thumbsAddedHandler);
-
myScroller.addEventListener(ThumbnailEvent.MOUSE_OVER, mouseOverHandler);
-
-
function thumbProgressHandler(event:ThumbnailEvent){
-
trace(event.item.bytesLoaded, event.item.bytesTotal);
-
}
-
-
function thumbsAddedHandler(event:ThumbnailEvent){
-
trace("all thumbnails are loaded");
-
}
-
-
function mouseOverHandler(event:ThumbnailEvent){
-
trace(event.item.id);
-
}
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.
June 2nd, 2008 at 2:15 am
Hi, is there a way to get an instance of the thumbnail in from the thumbscroller event? I know i can get the thumbnail index.
Or better yet, is there a way to just enable the thumbnail border only on the current mouse over?
June 2nd, 2008 at 4:20 pm
Hi,
To get the thumbnail instance you use
event.item, to get the instance of the border you useevent.item.border.You can’t enable the border for just a thumbnail, but what you can do is change the color of the selected thumbnail.
Here is an example: http://flashotaku.com/files/scroller_bordercolor.zip
What you could also do, is make all borders invisible and only the selected one visible.
June 14th, 2008 at 4:51 am
Hi, I am testing out your components and they are excellent! I have two ‘wishes’ in utilizing them and I wonder if you can tell me if they are possible:
1. Can I use the hand cursor on the slideshow for slides which have the urlPath set (and the regular pointer for others)?
2. I have the slideshow auto-playing with a timer, but also allow the user to click on a thumbnail scroller to view the images (which stops the auto play, obviously). When the user clicks I highlight the thumbnail border… is there a way that I could highlight the current thumbnail being shown while the slideshow is in auto-play mode?
Thanks!
June 14th, 2008 at 12:02 pm
Hi,
Yes, you can do both. Here’s a simple example:
http://flashotaku.com/files/gallery_ex6_as3.zip
June 19th, 2008 at 3:07 am
Thank you very much, got that part working in conjunction with a couple of other features that you outlined in other examples - great components and I will definitely give you a link once we get the site up and running!
I ran into an issue, but have not debugged it extensively - I was not able to change the xml (via code) to a sub directory (slideshow/slides.xml). I suspect it is something that I am doing, but could you tell me if it is using a URLRequest to get the XML or another method as that might help me diagnose my issue…
Thanks again!
June 20th, 2008 at 1:32 pm
Maybe the path to the XML file was not correct. Try using an absolute path.
June 23rd, 2008 at 2:23 pm
Hello FlashOtaku,
Thank you for your respond, i am working on it:)
Regarding to gallery_ex6_as3.zip, i wonder to know
Will it be possible when the “red border highlights” move to right, so the thumbs to move to the left and when it reached to the end, to start from first thumb again?
June 24th, 2008 at 10:51 am
I think I don’t understand your question. In my example, after the last thumbnail is highlighted, it goes to the first thumbnail again.
June 29th, 2008 at 11:08 pm
Hi-
Thanks for making such a great component available! Is there a way to ease the cMoveStop() function?
Thanks!
John
June 30th, 2008 at 12:14 pm
Hi,
For now, you can’t ease the cMoveStop() function.
August 9th, 2008 at 7:44 am
Hi how can I change the border thickness of a rollover thumbnail just like change of color effect, but chance color and thickness
By the way your component is great.
August 9th, 2008 at 8:07 am
and if there a way to create a tooltip on rollover thumb???
August 11th, 2008 at 3:41 pm
Hi,
Changing the borderThickness property for only one thumbnail is not possible but you could scale the border of the selected thumbnail the same you do with the color, but that would not look too good.
If you want to try, add this tween in the same place the clor tween is:
Tweener.addTween(event.item.border, {scaleX:1.1, scaleY:1.1 time:.3, transition:”linear”});
August 11th, 2008 at 3:43 pm
yes, you can create a tooltip on rollover
myScroller.addEventListener(ThumbnailEvent.MOUSE_OVER, mouseOverHandler);
myScroller.addEventListener(ThumbnailEvent.MOUSE_OUT, mouseOutHandler);
function mouseOverHandler(event:ThumbnailEvent)
{
// add tooltip
}
function mouseOutHandler(event:ThumbnailEvent)
{
// remove tooltip
}
August 14th, 2008 at 7:36 am
Hi FlashOtaku,
You make very nice as3 components!
Makes life of a as3 newbee a lot easier.
Do you have an example of adding a title/text to the
thumnail xml and showing this title/text on the thumbnail?
Keep up the good work!
August 14th, 2008 at 1:14 pm
Hi Marc,
Here’s a simple example: http://flashotaku.com/files/scroller_text_as3.zip
August 14th, 2008 at 10:09 pm
Hi FlashOtaku,
Example works fine!
I have to extract the thumbs and titles from a external complex xml-feed.
Is it possible to create the thumbs using my own xml routine? without using
the configurable xml attribute of the component?
Thanx for your quick response!
August 15th, 2008 at 3:04 pm
Hi Marc,
The structure of the XML file must be the same as in the examples and the attribute for the path must be “path”.
However, a workaround for this would be to use something like PHP to create the XML file that you pass to the component. You take the needed data from your xml-feed and then, using PHP, you create a new XML file with the required structure.
September 9th, 2008 at 8:13 pm
Hi,
First of all, the thumbnailscroller is a nice component.
But, I have a problem.
When I put the scroller in a movieclip and I test it, then it works, when I publish this site, then it will not work?
Wat do I wrong??
Thx,
Dimi
September 9th, 2008 at 11:38 pm
Hi,
That’s probably a path issue. Try using absolute paths instead of relative paths.
e.g. myScroller.xmlPath = “http://www.somedomain.com/xml/images.xml”
and in your XML file
<image path=”http://www.somedomain.com/images/image1.jpg”>
September 10th, 2008 at 11:56 am
Hi,
Thank you for the quick reply.
I will try this and come to you later.
Thx,
Dimi
September 10th, 2008 at 12:53 pm
Hi,
It was like you say, I set the absolute path and it was ok. So, thank you verry much and I hope to see more of this usefell things.
Thx,
Dimi
September 16th, 2008 at 2:10 pm
Hi,
Does anybody know why myScroller.speed is not working?
I’m using myScroller.mouseMove = true; so it should be working.
Thx,
Tom
September 16th, 2008 at 3:05 pm
Hi,
There seems to be a bug. It only works if you set the speed in the Component Inspector.
September 17th, 2008 at 7:44 am
thank you very much.. :) it works..
September 23rd, 2008 at 7:03 am
Is it possible to change the alpha of a thumbnail?
Absolutely great component.
Thanks!
September 23rd, 2008 at 11:16 am
Yes, it’s possible. If you just want the thumbnails to appear with an alpha of 0.5, for example, you need to add this code:
import com.flashotaku.thumbnailscroller.events.ThumbnailEvent;
myScroller.addEventListener(ThumbnailEvent.THUMB_INIT, thumbInitHandler);
function thumbInitHandler(event:ThumbnailEvent):void
{
event.item.child.alpha = 0.5
}
If you want to create a rollover effect, see this tutorial: http://flashotaku.com/blog/roll-over-effect-for-the-thumbnailscroller/
October 3rd, 2008 at 3:42 pm
hi, im not new to as3, and im familiar with xml. but im having trouble.
im trying to access multiple xml files from the main xml file.
and ive tried the MovieClip.myScroller.xmlPath = “someString”;
but i cant seem to figure out why its not working.
it keeps throwing “Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.” and then i tried another way and got “incorrect path to xml file”.
so im at a loss. it would be awesome if you could help.
October 3rd, 2008 at 4:49 pm
Hi,
IOErrorEvent indicates that inside your XML file, the path to the image is not correct.
October 3rd, 2008 at 7:10 pm
thanks a ton, i figured it out.
that actually wasnt the problem.
i guess for the xmlPath, you cant have someFolder/file.xml.
what i had was movieClip.myScroller.xmlPath = someFolder/file.xml
when it should of been movieClip.myScroller.xmlPath = file.xml
thanks
October 3rd, 2008 at 8:14 pm
Actually, you can have something like xmlPath = “files/xml/images.xml”. But you need to make sure it’s the correct path. The paths always need to be relative to your SWF file.
October 6th, 2008 at 10:22 am
Hi, i’m using myScroller.moveDown(); and myScroller.moveUp();
I would like to know how can i move my scroller 2 * myScroller.moveDown(); ?
Thanks
October 6th, 2008 at 11:31 am
If you want the scroller to move more when you call those methods, you need to set the moveAmount property to a higher value.
example:
myScroller.moveAmount = 200October 6th, 2008 at 1:34 pm
It works.
thanks you
October 15th, 2008 at 10:56 am
Hallo Flashotaku,
I’ve incorporated the AS3 thumbnail component into my navigation module and added a previous & next button. Is there a way to get the total of thumbs loaded? Im trying to make the “previous” button invisible at start. Or de “next” button invisible at the end of a list. For this i need to know at runtime myScroller.totalThumbnails.
is there a way to get this info?
Hope you can help.
Ludd, Amsterdam
October 15th, 2008 at 3:26 pm
Hi Ludd,
You can only find the total number of thumbnails if you parse the XML file.
var urlRequest:URLRequest = new URLRequest(”images.xml”);
var urlLoader:URLLoader = new URLLoader(urlRequest);
var totalThumbnails:int;
urlLoader.addEventListener(Event.COMPLETE, xmlCompleteHandler);
function xmlCompleteHandler(event:Event)
{
var xmlList:XMLList;
var xml:XML = new XML(event.target.data);
totalThumbnails = xml.children().length();
}
October 17th, 2008 at 8:12 pm
Thank you very much.
I tried a different approach by storing the value send by the ThumbnailEvent.THUMB_INIT into a preinstantiated Array. than used the ThumbnailEvent.ALL_THUMBS_ADDED to get total Thumbs.
private function onThumbsInit(evnt:Event):void{
// Array declared in main class
aThumbs.push(evnt.item);
}
private function onAllItemsAdded(evnt:Events):void{
var totalThumbs:uint = aThumbs.length;
trace(”Total thumbnails: “+ totalThumbs);
}
I enjoy working with you components.
great job.
October 24th, 2008 at 1:42 am
Hi, really great component. However I am frequently getting this error…
TypeError: Error #2007: Parameter url must be non-null.
at flash.display::Loader/_load()
at flash.display::Loader/load()
at com.flashotaku.thumbnailscroller::ThumbnailScroller/createThumbs()
at com.flashotaku.thumbnailscroller::ThumbnailScroller/completeHandler()
I’m using the component with a few different galleries and this error seems to happen when I change galleries too quickly… I guess before the images could finish loading maybe. Any ideas how I can fix this? Thanks in advance for any insight.
October 24th, 2008 at 3:01 pm
Hi,
It’s hard to find a solution unless I see some code.
If you want, you can post your code or send me your file at flashotaku [at] gmail [dot] com
October 24th, 2008 at 4:56 pm
I was wondering I like your components and have been trying to create something like this with a tilelist… however failing with every theory i put into practice.
I would like to be able to load an SWF into the slide show window… and then once i like on an image from the thumbnail slider… have it fill a movieclip with in the swf which is inside the slideshow window.
I have seen this done in some way and can not find a way of replicating it.
Figured maybe you might have some points or I can work with you and your components to accomplish this greater task?
interested?
October 27th, 2008 at 2:14 pm
If you’re interested about how the scroller and the slideshow communicate, it’s pretty easy. Each component has an array containing the path to the images, so each image has an index number. When you click on an image from the scroller you dispatch an event that has a property representing the index numeber of the image you’ve clicked. Now, knowing the index of the clicked image, you simply open the image with the same index from the slideshow.
October 27th, 2008 at 8:40 pm
Hi,
I haven’t checked if this has been asked before…
Is there a way to have variable sized thumbnails? I mean having for example a thumbnail of 70×70 and after it a thumbnail of 100×70. Thank you!
March 9th, 2009 at 7:44 pm
FLashOtaku, What do you mean when you say that the images path must be relative to the flash movie path? I am having an issue with a banner that reads image paths from a xml file. My images can reside even in different servers. I can pass my links alright to my banner but my images don’t show. Any thoughts?
March 10th, 2009 at 12:12 pm
If you load movie.swf into page.html, the path to the XML file and also the path to each image, which you write inside the XML file, need to be relative to page.html.
Or you could just use absolute paths.
March 11th, 2009 at 1:06 pm
[...] « ThumbnailScroller Component AS2 Documentation ThumbnailScroller Component AS3 Documentation [...]
May 29th, 2009 at 7:36 pm
first, your components are AWESOME! you ROCK!
second, is it possible to control the position of the thumbnails from a button on the stage? i.e. clicking a button on the stage triggers the scrollbar to advance to a particular thumbnail.
cheers!
May 29th, 2009 at 9:30 pm
Hi,
It’s not possible with the free version but it’s possible with the commercial version:http://flashotaku.com/components/thumbnail-scroller/
October 1st, 2009 at 12:47 pm
hi
nice component.
I would like to set the original border for each thumbnail to FALSE or alpha =0, and only the selected image border color=black, thickness 2, alpha =100. How can i do that?
please help.