Create MovieClip Scroller
| Language Version : | ActionScript 3.0 |
| Runtime Versions : | AIR 1.0, Flash Player 9.0.28.0 |
The ScrollBar component provides the end user with a way to control the portion of data that is displayed when there is too much data to fit in the display area. The scroll bar consists of four parts: two arrow buttons, a track, and a thumb. The position of the thumb and display of the buttons depends on the current state of the scroll bar. The scroll bar uses four parameters to calculate its display state: a minimum range value; a maximum range value; a current position that must be within the range values; and a viewport size that must be equal to or less than the range and represents the number of items in the range that can be displayed at the same time.
This tutorial will teach you how to create your own movie clip scroller. We will use ActionScript 3 for the interaction and functionality as usual. The Flash movie can be very easily modified to fit your needs!
Setting up the environment
1. Create a new ActionScript 3 Flash movie of size 300×300.
2. Draw a rectangle of size 200×250. This will act as a mask for the content.
3. Convert the rectangle to a movie clip. Set the registration point to the top left corner.
4. Give the movie clip an instance name of myMask. Position it somewhere on the left side of the stage. Our scrollbar will be on the right side…
4. Draw a line of size 1×250 on the right side of the stage.
5. Next, draw a circle of size 20×20. Convert it to a movie clip. Set the registration point to the center.
6. Give the circle an instance name of scrollMC.
7. Snap the circle to the top of the line that we drew earlier.

8. Next we want to make the content. You can freely create your own content here! The only restriction is that you must make it 200 pixels wide. I inserted some static text and an image. My content ended up being 940 pixels high.
9. Convert all the content stuff to a single movie clip. Set the registration point to the top left corner.

10. Give the content an instance name of myContent.
11. We are done with setting up the Flash movie. Now we can move to ActionScript 3. Your stage should look something like the image below (my content is outside the stage).
Moving to ActionScript 3
12. Create a layer for ActionScript and type the following.
//Import TweenMax and the plugin for the blur filter
import gs.TweenMax;
import gs.plugins.BlurFilterPlugin;
//Save the content's and mask's height.
//Assign your own content height here!!
var CONTENT_HEIGHT:Number = 940;
var MASK_HEIGHT:Number = 250;
//We want to know what was the previous y coordinate of the content (for the animation)
var oldY:Number = myContent.y;
//Position the content on the top left corner of the mask
myContent.x = myMask.x;
myContent.y = myMask.y;
//Set the mask to our content
myContent.mask = myMask;
//Create a rectangle that will act as the bounds to the scrollMC.
//This way the scrollMC can only be dragged along the line.
var bounds:Rectangle = new Rectangle(scrollMC.x,scrollMC.y,0,250);
//We want to know when the user is scrolling
var scrolling:Boolean = false;
//Listen when the user is holding the mouse down on the scrollMC
scrollMC.addEventListener(MouseEvent.MOUSE_DOWN, startScroll);
//Listen when the user releases the mouse button
stage.addEventListener(MouseEvent.MOUSE_UP, stopScroll);
//This function is called when the user is dragging the scrollMC
function startScroll(e:Event):void {
//Set scrolling to true
scrolling = true;
//Start dragging the scrollMC
scrollMC.startDrag(false,bounds);
}
//This function is called when the user stops dragging the scrollMC
function stopScroll(e:Event):void {
//Set scrolling to false
scrolling = false;
//Stop the drag
scrollMC.stopDrag();
}
//Add ENTER_FRAME to animate the scroll
addEventListener(Event.ENTER_FRAME, enterHandler);
//This function is called in each frame
function enterHandler(e:Event):void {
//Check if we are scrolling
if (scrolling == true) {
//Calculate the distance how far the scrollMC is from the top
var distance:Number = Math.round(scrollMC.y - bounds.y);
//Calculate the percentage of the distance from the line height.
//So when the scrollMC is on top, percentage is 0 and when its
//at the bottom the percentage is 1.
var percentage:Number = distance / MASK_HEIGHT;
//Save the old y coordinate
oldY = myContent.y;
//Calculate a new y target coordinate for the content.
//We subtract the mask's height from the contentHeight.
//Otherwise the content would move too far up when we scroll down.
//Remove the subraction to see for yourself!
var targetY:Number = -((CONTENT_HEIGHT - MASK_HEIGHT) * percentage) + myMask.y;
//We only want to animate the scroll if the old y is different from the new y.
//In our movie we animate the scroll if the difference is bigger than 5 pixels.
if (Math.abs(oldY - targetY) > 5) {
//Tween the content to the new location.
//Call the function tweenFinished() when the tween is complete.
TweenMax.to(myContent, 0.3, {y: targetY, blurFilter:{blurX:22, blurY:22}, onComplete: tweenFinished});
}
}
}
//This function is called when the tween is finished
function tweenFinished():void {
//Tween the content back to "normal" (= remove blur)
TweenMax.to(myContent, 0.3, {blurFilter:{blurX:0, blurY:0}});
}
13. You are done, test your movie!
Similar Posts:
- How to Design a flash menu with rollover effect
- Easy Scrolling text
- How to Create scroll buttons: automatic flash scroll
- Basics of ActionScript
- Flash mouse follow with ActionScript 3
- Flash 3D Tunnel with ActionScript 3
- How to Create 3D Boxes via ActionScript 3 – Part 1
- Create a Basic Animating Accordion Panel in Flash
- Advanced Flash XML Menu
- Flash 3D Tunnel Around Text
Enjoy this article?
Pages
Advertise Here
Categories
- ActionScript
- design
- Flash animation
- flash conf
- Flash cs3
- Flash CS4
- flash dhtml
- flash scripts
- Flash Sound
- Flash Video Tutorials
- Google Maps
- How To
- JavaScript
- PSP
Archives
Tags
Recent Posts
- How to use Flash stroke and Tools panel
- AS3 Custom Cursor
- How to create Flash Bubble effect
- How to Create and edit a gradient fill
- How To Create or edit a solid color
- Flash CS4 Color palettes
- Flash CS4 Color panel
- How to install flash player on ubuntu 64 bit
- How to Create and manage Flash projects
- How to Use flash templates
- Easy Scrolling text
- How to Substitute Missing Fonts
- How to Link horizontal text to a URL
- How to Check spelling a Flash document
- How to Create and edit text fields
Random Posts
- How to Create scroll buttons: automatic flash scroll
- Convert Flash Video FLV to M4V for Playback on iPod
- How to install flash player on ubuntu 64 bit
- How to Create flash Animation
- How to do easy Animation in animation on Flash CS3 Pro
- How to Create and Use a Motion Tween (Flash CS4)
- Snow Fall - Realistic Flash Falling Snow
- Flash Actionscript getURL
- Fix Mouse Clicks Not Working in Flash and Ubuntu
- how to install the Adobe Flash Player on Debian systems
links
Similar Articles
- iPhone flash plugin
- videohamster
- ipod videohamster com
- flash player iphone 3g
- videohamster com
- how to install flash player on ipod touch
- flash circular menu tutorial as3
- videohamster iPhone
- flash player for iphone 3g
- how to install flash player on iphone
- flash player iphone 3gs
- video hamster
- ipod video hamster
- ipod videohamster
- how to install flash player on fedora 12
- Adobe Flash Player error: could not load cURL library
- flash plugin iphone
- Iphone flash support
- flash player for psp go
- flash cs4 gradient mask
- fedora chrome flash
- freebsd 8 firefox flash plugin
- animated background flash cs4
- fedora 12 chrome flash
- video hamster not working
- Adobe Flash Player for fedora 12
- chrome flash fedora
- circular flash clock
- flash cs4 sound tutorial
- install iphone flash plugin for safari browser
- flash plugin for iphone
- flash player for ipod touch
- ubuntu flash buttons not working
- flash count
- flashplayer-win xpi
- compile gnash 64-bit OR x64
- ubuntu 64 bit flash buttons not working
- flash player iphone
- xpi archive of the flash player plugin
- iPhone videohamster com
- FreeBSD 8 flash 10
- fedora chrome flash
- gnash firefox
- how to install adobe flash player on fedora 12
- www iPod videohamster com
- flash timeline control
- how to click an option and display an image flash cs4
- videohamsterhqhd
- gradient mask in flash cs4
- flash cs4 alpha mask
- plugin flash iPhone
- how to install flash player in fedora 12
- npviewer button not clickable
- loadvariables as3
- click and reveal in flash
- generate thumb in flash
- timer flash tutorial
- how to make youtube work on psp
- installing flash10 plugin
- psp flash player
- flash countdown timer
- 10 0 42 34 installed
- slackware firefox plugin directory
- iPod videohamster com/
- freebsd 8 flash
- flash cs4 alpha
- flash player for psp
- iphone 3gs flash player
- install flash on iphone
- flash player for iphone 3gs
- gradient mask flash cs4
- install flash player iphone 3g
- macromedia flash enabled psp
- flash player fedora 12 chrome
- show text on mouseover in flash cs4
- flash chrome fedora
- how we can install a adobe flash playe on redhat linux
- XMLDataSource flash
- actionscript keyboardevent
- ubuntu flash not clickable
- flash player on iphone 3g
- actionscript 3 color picker
- debian flash video
- chrome flash 10 ubuntu
- adobe flash player ubuntu chrome amd64
- php mysql example for loading markers data via Google api
- flash on chrome ubuntu 64bit
- flash player for mandriva
- Scroll button tutorial flash cs4
- clearInterval as3
- flash as3 append text
- flash player for itouch 3g
- Agree and install now
- actionscript 3 countdown 90 minutes
- Adobe Flash Player error could not load cURL library
- flash plugin for iphone
- iPhone 3g flash player
- colorpicker flash cs4
- install adobe flash player without administrator
- flash cs4 on click jump to frame
Active Posts
- flash how to get thing to stop and text shown when mouse over
- flash cs4 tutorial motion tween guides
- open pdf from flash script
- flash cs4 stop action
- wine ubuntu 9 10 adobe flash CS4
- how to set shadow AS3 for button
- flash count up tutorial
- how to make a menu in flash cs4
- flash plugins 64 bit for fedora 12
- flash plugins 64 bit for fedora 12
- can google chrome play flash actionscript 2 files
- flash support button
- as3 create mask dynamically with anchor points
- color picker as3
- actionscript3 timer stop pause and play
- steps to uninstall fedora
- importing gradients using external classes in AS3
- howto install flash player without root
- mozila na psp
- freebsd epiphany flash
- flashplugin slackware
- loading animation as2 script
- animating colour change in AS2
- iphone: create dynamic button
- how to get a symbol to follow mouse in flash cs4
- how to make a menu in flash cs4
- as3 create mask dynamically bezier curves
- flash player chrome linux 64bit
- going back one frame in ActionScript 3 0
- flash*click button to scroll video
- enable flashplayer on psp root of mem
- as3 CS4 scrollable text tutorial
- making countdown animation in adobe cs3
- filereference images actionscript 3 tutorial
- as2 fscommand
- change flash document size as3
- change flash document width as3
- actionscript 3 0 linking pdf files
- custom drawing tool in Flash AS3
- fedora 12 64 bit flash plugin
- play/pause button flash cs4
- open pdf in flash movie
- as3 smooth follow
- where does libflashplayer so go ubuntu
- actionscript 2 tween setRGB
- weichzeichnen actionscript 3 mouseOver
- Adobe flash player not working with mandriva
- get url flash as3
- circle pulse in flash animation
- as3 animated loader tutorial circle
- create a movie clip on the stage from the library with flash as3
- flash as3 maze
- flash tutorial random movie frame
- make text show letter by letter actionscript3 0
- 6845
- adobe flash cs4 text fade in
- alligator move on path
- Remember that if you need the Flash Player to work with pulse you can ask libasound to do so in your ~/ asoundrc:
- easing in rotating wheel slow down in Flash tutorial fla
- flash draw bezier line
- Falsh CS4 stop button actionscript 3 0
- TweenMax text
- preloader and menu for flash movie
- static google maps api in flex
- Scrolling dynamic Text in Flash CS4
- actionscript 2 rewind
- how to get a something to follow your mouse in flash cs4
- flash tutorial for hide the object
- how to manage flash menu
- flash cs4 mouse tutorial run away
- changing registration point of loaded swf flash cs4
- enable shockwave flash active x in powerpoint
- as3 control glow effect
- flash variable text symbol
- smooth masking in flash
- range zoom in google map flash api
- flex 3 image mouseover
- code Skip intro flash as3
- fedora 12 fast video playback problem
- how to make mouseover animation

March 9th, 2010 - 13:01
A link to the classes you’ve use would be nice….
import gs.TweenMax;
import gs.plugins.BlurFilterPlugin;
March 9th, 2010 - 13:17
you need to install gs.classes ( TweenMax ) from the http://www.greensock.com/tweenmax/ then Import the class into your project.