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

Obfuscated Slider

Get Adobe Flash player
by shapevent 16 Nov 2009
/**
 * Copyright shapevent ( http://wonderfl.net/user/shapevent )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/z5AS
 */

package {
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import flash.text.*;
    public class FlashTest extends Sprite {
        public function FlashTest() {
            
            var txt:TextField = TextField(addChild(new TextField()));
            txt.text = "drag circle";
            var slider:MovieClip = makeSlider();
            slider.addEventListener(Event.CHANGE, function(evt:Event):void{
	      trace(evt.currentTarget.percent);	
              txt.text = evt.currentTarget.percent;								
            });
            
        }
        private function makeSlider():MovieClip{
    	var slider:MovieClip = MovieClip(addChild(new MovieClip()));
	var circle:Sprite = Sprite(slider.addChild(new Sprite()));
	with (circle.graphics) beginFill(0x000000), drawCircle(0,0,10);
	var line:Shape = Shape(slider.addChild(new Shape()));
	with (line.graphics) lineStyle(0,0x000000), lineTo(0, 100);
	slider.x = slider.y = 100;
	circle.addEventListener(MouseEvent.MOUSE_DOWN, function(evt:Event):void{ evt.currentTarget.startDrag(false, new Rectangle(0,0,0,100)), slider.addEventListener(Event.ENTER_FRAME, onChange) });
	var stopIt:Function = function():void{ stopDrag(), slider.removeEventListener(Event.ENTER_FRAME, onChange) };
	stage.addEventListener(Event.MOUSE_LEAVE, stopIt);
	stage.addEventListener(MouseEvent.MOUSE_UP, stopIt);
	return slider;
        }
        private function onChange(evt:Event):void { evt.currentTarget.percent = evt.currentTarget.getChildAt(0).y / 100, evt.currentTarget.dispatchEvent(new Event(Event.CHANGE)) }

    }
}