PROGRAMMING COURSES ADMIN VIDEO TUTORIALS COMMUNITY RESOURCES |
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();
|
||||||||||||
|
|
DevelopPHP Requires Flash Player
___________________________________________
|
||||||||