[Help] Inertia, elasticity

Hi All,

[COLOR=#333333]I’m trying to build something similar to Oxylus (http://www.oxylusflash.com/flashfiles/easy-before-and-after-photo-mask-as3) to display before/after images.

[/COLOR]
[COLOR=#333333]What I like of this “slider” is the “inertia”, “elasticity” that has. The code of Oxylus works with a lot of “external” files. I’m trying to get to someghing similar but embeed in a single swf movie. [/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333]This is the code I have so far, but there’s no elasticity or inertia in the slider. Could someone help to add that physic property to this code?

[/COLOR]
[HR][/HR]

[COLOR=#333333]var _before:Bitmap = new Bitmap(new Before(0,0));[/COLOR]
[COLOR=#333333]var _after:Bitmap = new Bitmap(new After(0,0));[/COLOR]
[COLOR=#333333]var _slider:Slidebar = new Slidebar();[/COLOR]
[COLOR=#333333]var _mask:Sprite = new Sprite();[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333]function Init() : void [/COLOR]
[COLOR=#333333]{ [/COLOR]
[COLOR=#333333] _mask.graphics.beginFill(0x000000);[/COLOR]
[COLOR=#333333] _mask.graphics.drawRect(0,0,1280,962);[/COLOR]
[COLOR=#333333] _mask.graphics.endFill();[/COLOR]

[COLOR=#333333] addChild(_mask);[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333] _after.mask = _mask;[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333] addChild(_before);[/COLOR]
[COLOR=#333333] addChild(_after);[/COLOR]
[COLOR=#333333] addChild(_slider);[/COLOR]

[COLOR=#333333] _slider.x = 640;[/COLOR]
[COLOR=#333333] _mask.x = _slider.x;[/COLOR]
[COLOR=#333333] _slider.y = 481;[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333] _slider.buttonMode = true; [/COLOR]
[COLOR=#333333] _slider.addEventListener(MouseEvent.MOUSE_DOWN, SlidebarEvents, false, 0, true); [/COLOR]

[COLOR=#333333] stage.addEventListener(MouseEvent.MOUSE_UP, StopEvents, false, 0, true); [/COLOR]

[COLOR=#333333]} [/COLOR]

[COLOR=#333333]function SlidebarEvents($e:MouseEvent):void[/COLOR]
[COLOR=#333333]{ [/COLOR]
[COLOR=#333333] stage.addEventListener(MouseEvent.MOUSE_MOVE, Move, false, 0, true);[/COLOR]
[COLOR=#333333]} [/COLOR]

[COLOR=#333333]function StopEvents($e:MouseEvent):void[/COLOR]
[COLOR=#333333]{ [/COLOR]
[COLOR=#333333] stage.removeEventListener(MouseEvent.MOUSE_MOVE,Move);[/COLOR]
[COLOR=#333333]}[/COLOR]

[COLOR=#333333]function Move(event:MouseEvent):void[/COLOR]
[COLOR=#333333]{[/COLOR]
[COLOR=#333333] _slider.x = mouseX;[/COLOR]
[COLOR=#333333] if (_slider.x > stage.stageWidth){[/COLOR]
[COLOR=#333333] _slider.x = stage.stageWidth;[/COLOR]
[COLOR=#333333] }[/COLOR]
[COLOR=#333333] else if(_slider.x < 0){[/COLOR]
[COLOR=#333333] _slider.x = 0;[/COLOR]
[COLOR=#333333] }[/COLOR]

[COLOR=#333333] _mask.x = _slider.x;[/COLOR]
[COLOR=#333333]}[/COLOR]
[COLOR=#333333]
[/COLOR]
[COLOR=#333333][FONT=Courier]Init();
[/FONT][/COLOR]

[HR][/HR]

Thanks in advance!