ThumbnailScroller Component AS2 Documentation
Actionscript 2, Documentation, Flash Components December 20th, 2007Here is the documentation for the ThumbnailScroller Component AS2. 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 8, Flash CS3
Actionscript: Actionscript 2 (Actionscript 3 version available here)
Player: Flash Player 8, Flash Player 9
Methods
moveRight()
moveLeft()
moveUp()
moveDown()
example:
-
right.onRelease = function(){
-
myScroller.moveRight();
-
}
-
-
left.onRelease = function(){
-
myScroller.moveLeft();
-
}
cMoveRight()
cMoveLeft()
cMoveUp()
cMoveStop()
example:
-
right.onRollOver = function(){
-
myScroller.cMoveRight();
-
}
-
left.onRollOver = function(){
-
myScroller.cMoveLeft();
-
}
-
right.onRollOut = left.onRollOut = function(){
-
myScroller.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;
handCursor
-type:Boolean
-defaultValue: false
example: myScroller.handCursor = true;
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 = 0x33ffcc;
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 = 0x33ff00;
preloaderLineColor
- type:Number
- default value: #ffffff
example: myScroller.preloaderLineColor = 0x33cc33;
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 = 0x33ff00;
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
onLoadXML
- dispatched when the loading of the XML file is complete
onThumbStart
- dispatched when the loading of a thumbnail is starting
onThumbProgress
- dispatched when a thumbnail is loading
onThumbComplete
- dispatched when the loading of a thumbnail is complete
onThumbInit
- dispatched when the properties of a thumbnail are available
allThumbsAdded
- dispatched when all the thumbnails are loaded
release
- dispatched when the user releases the mouse over a slide
rollOver
- dispatched when the user moves the mouse over a slide
rollOut
- dispatched when the user moves the mouse away from a slide
example:
-
var initObject:Object = new Object();
-
var progressObject:Object = new Object();
-
var allThumbsObject:Object = new Object();
-
-
myScroller.addEventListener("onThumbInit", initObject);
-
myScroller.addEventListener("onThumbProgress", progressObject);
-
myScroller.addEventListener("allThumbsAdded", allThumbsObject);
-
-
initObject.onThumbInit = function(evt:Object){
-
trace(evt.target.id);
-
}
-
-
progressObject.onThumbProgress = function(evt:Object){
-
trace(evt.target.bytesLoaded);
-
trace(evt.target.bytesLoaded);
-
}
-
-
allThumbsObject.allThumbsAdded = function(evt:Object){
-
trace("all thumbnails are loaded");
-
}
February 6th, 2008 at 3:13 pm
guys, this looks great, one question, is there a way to add links to the images? for example that a user will view the images and will click on one of them to see a bigger image or will be directed to a different html page?
Thanks
Ziv
February 6th, 2008 at 3:44 pm
Hi Ziv
These tutorials show you how to do that:
http://flashotaku.com/blog/image-gallery-tutorial-example-1/
http://flashotaku.com/blog/image-gallery-tutorial-example-2/
http://flashotaku.com/blog/open-url-when-a-thumbnail-is-clicked/
(for the last tutorial I’ve made only the AS3 version but it’s similar in AS2)
March 22nd, 2008 at 8:10 pm
Is there any chance, that you’ll share the source with us? It’ll be really useful :) Anyway thanks for your great job!
March 22nd, 2008 at 8:51 pm
There is a bug in ‘onThumbInit’ event. You can’t get the proper _width and _height value of thumbnail. It’s a real problem when you’re using ‘maintain aspect ratio’ mode :(
March 22nd, 2008 at 9:39 pm
I’ve fixed the bug. You can re-download the component.
March 22nd, 2008 at 11:01 pm
Thnx! It’s working now :) I’ve already overcome this issue by ‘setTimeout’ but, it was of course a bug.
I’m understand that this will never be ‘open source’?
March 24th, 2008 at 10:16 pm
Probably not in the near future
March 25th, 2008 at 9:18 am
Hi there,
Is there a tween complete event available..? I want to stop the left and right buttons working whilst the thumbnail is scrolling as if a user presses the button before it stops it messes up the positioning of the thumbnails.
Thanks
Rolf
March 25th, 2008 at 1:23 pm
Hi
There isn’t a tween complete event but you know the duration of the tween…
March 25th, 2008 at 2:49 pm
Yes thanks, thats how I have done it…disabled the movieclip button once it has been pressed and then used setinterval to enable it once that time has passed.
April 5th, 2008 at 10:36 pm
Thanks for the component,it’s great I tried to use useHandcursor it displayed the Handcursor,but didn’t work
myScroller.onRollOver = function(){
myScroller.useHandCursor = true;
}
April 10th, 2008 at 11:17 am
Is it possible to have the cursor change to hand while over the thumbnails (if not, than when over the whole component)?
Tried doing it with
“thumbnails.useHandCursor = true;”
where thumbnails is the component, but it didnt work.
April 10th, 2008 at 12:33 pm
I added this option . Please re-download the component.
To change to hand cursor set the handCursor property to true
myScroller.handCursor = true
April 17th, 2008 at 7:12 am
hi there,
I may be missing something, but i couldnt get the hand cursor to work. i re- downloaded the component, tried your demo file, adding myT.handCursor = true, but got no hand cursor.
Am i missing anything?
thanks,
YoS
April 17th, 2008 at 9:19 am
Hi,
The component in the demo doesn’t have the handCursor property because I didn’t modified the demo after I added the handCursor property, so that is still the old component.
If you reinstall the component (using the MXP file), the new component will have a handCursor property available.
April 17th, 2008 at 11:39 am
Thanks, yet again!
April 17th, 2008 at 11:55 am
You’re welcome :)
May 2nd, 2008 at 1:13 pm
Hi,
I was just wondering whether there is any way to make thumnailscroller, scroll automatically through the images as well as when clicking the buttons?
Awesome work btw :-)
May 2nd, 2008 at 1:51 pm
Hi,
I have worked it out! wasnt hard even for me!! haha
added this code at top:
var this_interval:Number = 5000;
function playInterval() {
myT.moveRight();
}
thanks!
May 2nd, 2008 at 3:02 pm
Hi Stylee,
Glad you’ve worked it out.
May 6th, 2008 at 3:42 pm
Hi again,
Not sure if im doing something wrong! I have dragged an instance of the scroller to my stage and all the different options work from the component inspector except for easing type and easing method!? Is there some actionscript i am missing?
Thanks
May 6th, 2008 at 6:39 pm
Hi Stylee,
That’s strange. I’ve checked the component and works fine for me if I change the easing using the component inspector.
May 7th, 2008 at 8:45 am
Hi
One difference i noticed from your source file and the instance i am using is that when i click the drop down for easying type all the options are a set in by a space apart from back! and back is the only one that works! I tried re-installing the mxp file again but no luck! Could this be an issue? I am using flash 8 as2!?
May 7th, 2008 at 1:26 pm
It’s very strange. It works fine for me and nobody reported this problem before. However, you could still set the easing using code:
myScroller.easingType = “Elastic”;
myScroller.easingMethod = “easeOut”;
May 29th, 2008 at 11:06 am
Hi Flash,
I dont know why it is doing that, but i have used the actionscript method instead, thanks.
I was wondering something else…not wanting to hassle you tho! How would i go about identifying how many images are in the xml, so if there is only one image my next and previous buttons wouldnt show as they are not needed. Is this quite a big work up?
Thanks for your support.
May 29th, 2008 at 1:51 pm
Hi,
To get the total number of images you would need to parse the XML file again.
See this simple example:
http://flashotaku.com/files/slideshow_c_as2.zip
It uses a slideshow but it’s the same with the scroller.
June 3rd, 2008 at 7:42 pm
Hi Flash,
I would like to know if have a method to load all thumbnail before then show the images. Because the component catch the image and move which one of the images to up. I prefer to load all before them show them.
How I could do that ?
Thanks for you support.
June 4th, 2008 at 4:47 pm
Hi Snow,
You could make your scroller invisible and when all thumbnails are loaded set the alpha back to 100. To know when all thumbnails are loaded you need to listen for the “allThumbsAdded” event to be dispatched.
var allThumbsObject:Object = new Object();myScroller._alpha = 0;
myScroller.addEventListener("allThumbsAdded", allThumbsObject);
allThumbsObject.allThumbsAdded = function(evt:Object)
{
myScroller._alpha = 100;
}
July 17th, 2008 at 9:48 am
Is there a way to make 2 vertical columns of thumbnails instead of just one?
July 17th, 2008 at 11:40 am
Unfortunately, there isn’t.
November 30th, 2008 at 10:30 am
I currently check for allThumbsAdded to set the alpha to 100 but this means there may be a long wait if there are lots for thumbs to load.
Is there another way that I can do this so that I can bring up the alpha to 100 after a certain number of thumbs are loaded rather than all of them?
For instances where the totalThumbs is less than 8 using the allThumbsAdded works fine for me but for instances where the totalThumbs exceeds 7 then I want to show the scroller once the first 7 are loaded.
In my script I’ve already calculated the value for totalThumbs so something like if totalThumbs <= 7 (use the allThumbsAdded method) else (use a different method).
December 1st, 2008 at 12:07 pm
You could use the onThumbInit event and check the id of the loaded thumbnail.
var thumbInitObj:Object = new Object();
thumbInitObj.onThumbInit = function(event:Object)
{
if(event.target.id >= 7)
{
myScroller._alpha = 100;
}
}
myScroller.addEventListener(“onThumbInit”, thumbInitObj);
March 11th, 2009 at 1:06 pm
[...] « Slideshow Component AS2 Documentation ThumbnailScroller Component AS2 Documentation [...]
September 6th, 2009 at 6:57 am
Hi Flash Otaku,
I want to add URL in XML file. I mean, I click to image and go to something web site or link. How to do please explain me. Thank