Develop PHP Website for Learning Web Design Free Online
  Home   |   Forums   |   DevCMS
  Join   |   Log In
 
   

Flash and ActionScript 3 Tutorials - Learn Flash and ActionScript 3

Tutor at Develop PHP
Content Scroll Bar 1.0 Tutorial
By: Adam      Created: Oct 24, 2008      Views: 27487 Tweet This Page  Post page to Facebook  Post page to Facebook

Download Source Files


In this Flash AS3 tutorial you can get a basic grasp of advanced custom scrolling with a scroll bar. With this mathematical foundation you can pull off a whole lot of custom movement and dynamic operation. This can be used in Flash CS3 and Flash CS4, and it is written using ActionScript 3. Download the free fla file below to dig into the file.




ActionScript 3.0 Code Reference
// Scroll My Content function - AS3
function scrollMyContent () {
// Cache the TextField as a bitmap to improve performance.
content_mc.cacheAsBitmap = true;
// Event Listeners
scrollDragger.addEventListener(MouseEvent.MOUSE_DOWN, scrollDraggerPress);
stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpOnStage);
// Set variables
var scrollbarHeight:Number = scrollbarBG.height;
var contentHeight:Number = content_mc.height;
var scrollDraggerHeight:Number = scrollDragger.height;
var maskHeight:Number = contentMask.height;
var scrollAmout:Number = (contentHeight-maskHeight)/(scrollbarHeight-scrollDraggerHeight);
var topBound:Number = scrollbarBG.y;
var bottomBound:Number = scrollbarBG.height-scrollDraggerHeight+scrollbarBG.y;
var startPos:Number = content_mc.y;
var leftBound:Number = scrollbarBG.x;
var absNumSet:Number = 0;

// When scrollDragger gets pressed we do this
function scrollDraggerPress(event:MouseEvent):void {
// Set bounds using some of the scroller BG properties claimed above
var bounds:Rectangle = new Rectangle(leftBound, topBound, 0, bottomBound);
scrollDragger.startDrag(false, bounds);
stage.addEventListener(MouseEvent.MOUSE_MOVE, reportStageMouse);
function reportStageMouse(event:MouseEvent):void {
absNumSet = Math.abs(scrollbarBG.y - scrollDragger.y);
content_mc.y = Math.round(absNumSet * - 1 * scrollAmout + startPos);
}
}
// When mouse is released while dragging we do this
function mouseUpOnStage(event:MouseEvent):void {
stopDrag();
}
}
scrollMyContent();



Comment on Content Scroll Bar 1.0 Tutorial

Search Tags:
scroll   ·  content   ·  bar   ·  drag   ·  mask   ·  text   ·  picture   ·  website   ·  site   ·  free   ·  tutorial   ·  video   ·  flash   ·  as3   ·  learn   ·  how   ·  tutorial   ·  source   ·  edit   ·  free   ·  actionscript   ·  3.0   ·  cs3   ·  cs4   ·  online   ·  
 
 
Arbitrary Links and Archives
Home
Active Forums
Members
SIte News
Link To Us
Gear
2009 Forum Archive
Programming Courses
Learn HTML
Learn CSS
Learn PHP
Learn MySQL
Learn Javascript
Learn jQuery
Learn ActionScript 3.0
Learn Java
Learn XML
DevelopPHP Requires Flash Player
Get Adobe Flash player
___________________________________________

Terms of Use  •  Privacy  •  Admin Notes

©2010 developphp.com   |   Powered By FlashBuildingHolder