Zoo2006-10-07_043Jikishinkageryu
Naginatajutsu
in Hyogo
Kenritsu
Budokan,
Himeji
2011-05-29Pakkas03Pitkanen_076Jodo-Pori.2010-07-17Helsinki2005-10-15_16_042Hannan-ja-Esan-haat.20100822.131652.703Nanbudo_Norge2007-12_038Minatogawa
Jinja,
Kobe
2011-06-20Shiga,
Japan
2010-04-18Kobujutsu
Stadion
2011-12-17
2Saaristoleiri-Uto-2008_180norge5oslo_169Slovenija
2010-11Hannan-ja-Esan-haat.20100821.180134.503Nanbudo_Norge2007-12_211Vesa-Rauttu-60v_1899Kuortti.2010-06-26Need for
umbrella
in Kobe
2011-06-10Kuortti.2010-06-26Oslo
2010-12-03Naginata
Helsinki
2010-02-07
09playa06secret_552
Lapo after rain

A wet dog after the rain has passed.

Scrolling content in Actionscript 3

I believe this example is available in my earlier tutorials fro Actionscript 2, but in order to simplify and to make it easier to be found, I have made a new one in Actionscript 3.

package org.paazio {
    import flash.display.*;
    import flash.events.*;
    import flash.ui.Keyboard;

    public class Scrolling extends Sprite {

        private var maskShape:Shape;
        public var content:Sprite;
        public var step:Number;

        /**
         *
         * @param    stuff    The stuff to be scrolled
         * @param    step    Amount of pixels for each step by keyboard or mousewheel
         * @param    w        Width of the mask
         * @param    h        Height of the mask
         */
        public function Scrolling(stuff:DisplayObject, step:Number = 5, w:Number = 100, h:Number = 150) {
            this.step = step;

            maskShape = new Shape();
            maskShape.graphics.beginFill(0x000000);
            maskShape.graphics.drawRect(0, 0, w, h);
            maskShape.graphics.endFill();
            this.addChild(maskShape);

            content = new Sprite();
            content.name = "content";
            content.addChild(stuff);
            content.mask = maskShape;
            this.addChild(content);

            this.addEventListener(MouseEvent.MOUSE_WHEEL, onMouseWheel);
            this.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
        }

        private function onMouseWheel(evt:MouseEvent):void {
            content.y += evt.delta / 2 * step;

            checkLimits();
        }

        private function onKeyUp(evt:KeyboardEvent):void {
            if (evt.keyCode == Keyboard.UP) {
                content.y -= step;
            }
            else if (evt.keyCode == Keyboard.DOWN) {
                content.y += step;
            }

            checkLimits();
        }

        /**
         * Checks for the assumed limits and resets to them if overlapped.
         */
        private function checkLimits():void {
            if (content.y > 0) {
                content.y = 0;
            }
            else if (content.y < (maskShape.height - content.height)) {
                content.y = maskShape.height - content.height;
            }
            stage.invalidate();
        }
    }
}

Please note that I have left one check out from the "checkLimits" function. It might sometimes happen that the mask is taller than the content...

Time: 04/04/2008 07:28

QR code for paazio.nanbudo.fi