I found a way to put it in a function and send a var as the name of the mc I want to control. So far this works great. I am sure someone from greensock might say I am doing something that I should not but here goes.
Note my var screenX is a var from the stage.StageWidth and the menuBanner.width is just moving the mc down on the screen. Keep this in mind as you use this function. Hope it helps someone.
Need the proper imports:
import flash.display.MovieClip;
import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
import flash.geom.Rectangle;
import flash.utils.getTimer;
import flash.events.MouseEvent;
import flash.text.*;
import flash.display.*;
TweenPlugin.activate([ThrowPropsPlugin]);
To call it use:
throwIt(yourMC);
public function throwIt(clipContent:MovieClip)
{
var bounds:Rectangle = new Rectangle(screenX - clipContent.width,0,1080,1920);
//var mc:Sprite = clipContent.getChildByName("content") as MovieClip;
var mc:Sprite = clipContent as MovieClip;
addChild(mc);
//some variables for tracking the velocity of mc
var t1:uint,t2:uint,y1:Number,y2:Number;
mc.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
TweenLite.killTweensOf(mc);
y1 = y2 = mc.y;
t1 = t2 = getTimer();
mc.startDrag(false, new Rectangle(bounds.x, -99999, 0, 99999999));
mc.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
function enterFrameHandler(event:Event):void
{
//track velocity using the last 2 frames for more accuracy
y2 = y1;
t2 = t1;
y1 = mc.y;
t1 = getTimer();
}
function mouseUpHandler(event:MouseEvent):void
{
mc.stopDrag();
mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
mc.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (mc.y - y2) / time;
var yOverlap:Number = Math.max(0,mc.height - bounds.height);
ThrowPropsPlugin.to(mc, {ease:Strong.easeOut, throwProps:{y:{velocity:yVelocity, max:bounds.top+menuBanner.height, min:bounds.top - yOverlap, resistance:100}}}, 3, 0.25, .3);
}
}