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

minimalcomps VScrollBar test

minimalcomps VScrollBar test
Get Adobe Flash player
by hacker_a7xbpc4j 20 Dec 2010
/**
 * Copyright hacker_a7xbpc4j ( http://wonderfl.net/user/hacker_a7xbpc4j )
 * GNU General Public License, v3 ( http://www.gnu.org/licenses/quick-guide-gplv3.html )
 * Downloaded from: http://wonderfl.net/c/t15Y
 */

package {
    import com.bit101.components.VBox;
    import com.bit101.components.VScrollBar;
    import flash.display.*;
    import flash.events.*;
    public class FlashTest extends Sprite {
            private var container: VBox;
     private var containerMask: Shape;
    private  var scrollBar:VScrollBar;
    private  var scoreLength:int;
    private  var myScoreLCIndex:int;
    private  var listChildren:Vector.<DisplayObject>;
    private  var scrollValue:int;
   private   var w:int = 200
   private   var h:int = 300;
    private  var UnitList:Sprite ;
        public function FlashTest() {
            UnitList = new Sprite();
            container = new VBox();
            addChild(UnitList);
           UnitList.x=10,UnitList.y=10;
                    
        UnitList.addChild(container);
        UnitList.addChild(containerMask = new Shape());
        container.mask=containerMask;
        var g:Graphics=containerMask.graphics;
        g.beginFill(0xFF00FF),g.drawRect(0,0,w,h);
        scrollBar=new VScrollBar(UnitList,w,0,onChangeScroll);
        scrollBar.height=h; 
        
        add([Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box,Box]);
        }
         private  function add(scores:Array):void {
    scoreLength = scores.length;
      listChildren=new Vector.<DisplayObject>(scoreLength,true);
      var hsum:int = 0;
    for (var i: int = 0; i < scoreLength; i++) {
        var s:Class = scores[i] as Class;
        var listChild:DisplayObject = new s();
        container.addChildAt(listChild, i);
        hsum += listChild.height;
    }
   scrollBar.setThumbPercent(h/(hsum-h));
    var max:int=hsum-h;
    if (max<0) {
        max=0;
    }
    scrollBar.setSliderParams(0, max, 0);
    scrollValue=0;
}
private function setScrollBar():void {
    scrollBar.setThumbPercent(h/(container.height-h));
    var max:int=container.height-h;
    if (max<0) {
        max=0;
    }
    scrollBar.setSliderParams(0, max, 0);
    scrollValue=0;

}

private function onChangeScroll(e:Event):void {
    trace(container.height,scrollBar.value);
    if (scrollValue==scrollBar.value) {
        return;
    }
    scrollValue=scrollBar.value;
    container.y=- scrollValue;
    trace(scrollValue)
}
    }
 

}
       
        
        





import flash.display.Sprite;
class Box extends Sprite{
    function Box(){
        graphics.beginFill(0x0);
        graphics.drawRect(0, 0, 200, 50);
        graphics.endFill();
    }
}