In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

ScrollBar

Get Adobe Flash player
by macomputer 07 Dec 2009
/**
 * Copyright macomputer ( http://wonderfl.net/user/macomputer )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/t6pe
 */

package {
    import flash.display.Sprite;
    import flash.display.Shape;
    import flash.display.Graphics;
    import flash.events.*;
    import flash.geom.Rectangle
    [SWF(backgroundColor="#FFFFFF", frameRate=30, width=600, height=600)]
    public class ScrollBar extends Sprite {
        public function ScrollBar() {
            //スクロールバー
            var barMc:Sprite = new Sprite();
            var bar:Shape = new Shape();
            barMc.addChild(bar);
            stage.addChild(barMc);
            var barGraphics:Graphics = bar.graphics;
            barGraphics.lineStyle(1, 0x000000, 0);
            barGraphics.beginFill(0x000000, 1.0);
            barGraphics.drawRect  ( 0, 0 , 10 , 100);
            barMc.x = 450;
            barMc.y = 100;
            
            //コンテンツ
            var conMc:Sprite = new Sprite();
            var con:Shape = new Shape();
            conMc.addChild(con);
            stage.addChild(conMc);
            var conGraphics:Graphics = con.graphics;
            conGraphics.lineStyle(1, 0x000000, 0);
            conGraphics.beginFill(0x000000, 1.0);
            conGraphics.drawRect  ( 0, 0 , 300 , 600);
            conMc.x = 100;
            conMc.y = 100;
            
            
            barMc.buttonMode = true;
            barMc.addEventListener(MouseEvent.MOUSE_DOWN, barDown);
            function barDown(e:MouseEvent):void{
                e.target.startDrag(false, new Rectangle(450,100,0,300));
                barMc.addEventListener(MouseEvent.MOUSE_UP, barUp);
                stage.addEventListener(MouseEvent.MOUSE_UP, barUp);
            }
            function barUp(e:MouseEvent):void{
                barMc.stopDrag();
                barMc.removeEventListener(MouseEvent.MOUSE_UP, barUp);
                stage.removeEventListener(MouseEvent.MOUSE_UP, barUp);
            }            
        }
    }
}