import com.greensock.*;
import com.greensock.plugins.*;
import com.greensock.easing.*;
import flash.display.*;
import flash.geom.*;
import flash.events.*;
import flash.utils.*;
TweenPlugin.activate([ThrowPropsPlugin]);
var t1:uint,t2:uint,y1:Number,y2:Number,x1:Number,x2:Number,xOffset:Number,yOffset:Number;
mc_square.addEventListener(MouseEvent.MOUSE_DOWN, start_drag);
function mouseMoveHandler(event:MouseEvent):void
{
mc_square.y = this.mouseY - yOffset;
mc_square.x = this.mouseX - xOffset;
var t:uint = getTimer();
if (t - t2 > 50)
{
x2 = x1;
x1 = mc_square.x;
y2 = y1;
t2 = t1;
y1 = mc_square.y;
t1 = t;
}
event.updateAfterEvent();
}
function start_drag(e:MouseEvent):void
{
TweenLite.killTweensOf(mc_square);
x1 = x2 = mc_square.x;
xOffset = this.mouseX - mc_square.x;
y1 = y2 = mc_square.y;
yOffset = this.mouseY - mc_square.y;
t1 = t2 = getTimer();
mc_square.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
mc_square.stage.addEventListener(MouseEvent.MOUSE_UP, stop_drag);
}
function stop_drag(e:MouseEvent):void
{
mc_square.stage.removeEventListener(MouseEvent.MOUSE_UP, stop_drag);
mc_square.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
var time:Number = (getTimer() - t2) / 1000;
var xVelocity:Number = (mc_square.x - x2) / time;
var yVelocity:Number = (mc_square.y - y2) / time;
ThrowPropsPlugin.to(mc_square, {throwProps:{y:{velocity:yVelocity, resistance:600},x:{velocity:xVelocity, resistance:600}}, ease:Strong.easeOut}, 1, 0.3, 1);
}
this is my code
i need to bound object on stage
thanks you for help and sorry for my bad english