Permalink
Browse files

Cleaned up Ease and fixed left over image shifting.

  • Loading branch information...
1 parent 11a2cec commit 7a232a77fe90b791d18a64052dd08cc1ddf55398 @jessefreeman jessefreeman committed Jun 21, 2010
View
@@ -137,7 +137,6 @@ package
{
scrubber = new HSlider(this, 0, 0, null);
scrubber.width = stage.stageWidth;
- scrubber.x = 20;
scrubber.y = 10;
}
@@ -25,7 +25,6 @@ package com.flashartofwar
protected var sourceRect:Rectangle;
protected var sourceBitmapData:BitmapData;
protected var leftOver:Number;
- protected var sampleAreaX:Number;
protected var point:Point;
protected var calculationPoint:Point = new Point();
protected var difference:Number;
@@ -202,17 +201,15 @@ package com.flashartofwar
sourceBitmapData = _bitmapDataCollection[collectionID];
- leftOver = calculateLeftOverValue(sampleArea.x, sampleArea.width, sourceRect);
-
- sampleAreaX = sampleArea.x;
+ leftOver = Math.round(calculateLeftOverValue(sampleArea.x, sampleArea.width, sourceRect));
if (!offset)
offset = copyPixelOffset;
point = calculateSamplePosition(sampleArea, sourceRect);
- sampleArea.x = Math.round(point.x);
- sampleArea.y = Math.round(point.y);
+ sampleArea.x = point.x;
+ sampleArea.y = point.y;
output.copyPixels(sourceBitmapData, sampleArea, offset);
@@ -5,11 +5,8 @@ package com.flashartofwar.behaviors {
public class EaseScrollBehavior extends EventDispatcher {
- private var _targetX:Number;
+ public var targetX:Number;
private var target:Object;
- private var time:int;
- private var defaultDuration:int = 500;
- private var duration:int;
public function EaseScrollBehavior(target:Object, targetX:Number = 0) {
@@ -19,48 +16,31 @@ package com.flashartofwar.behaviors {
else
{
this.target = target;
- _targetX = targetX;
+ targetX = targetX;
}
}
- public function set targetX(value:Number):void
- {
- if(_targetX == value)
- {
- return;
- }
- else
- {
- if((target.scrollX == _targetX))
- {
- time = getTimer();
- }
- else
- {
- duration += defaultDuration;
- }
- _targetX = value;
- }
- }
-
public function calculateScrollX():void
{
- if ((target.scrollX == _targetX))
+ if ((target.scrollX == targetX))
{
- duration = defaultDuration;
return;
}
else
{
- var interval:int = getTimer() - time;
//t: current time, b: beginning value, c: change in position, d: duration
- var c:Number = _targetX - target.scrollX;
- var t:Number = interval;
- var d:Number = duration;
+ var c:Number = targetX - target.scrollX;
+ var t:Number = .25;
+ var d:Number = .8;
var b:Number = target.scrollX;
target.scrollX = quadEaseInOut(t, b, c, d);
+
+ if(((c ^ (c >> 31)) - (c >> 31)) < .01)
+ {
+ target.scrollX = targetX;
+ }
}

0 comments on commit 7a232a7

Please sign in to comment.