How to widen up the sound wave in AS3? - actionscript-3

I am implementing this code for drawing the sound wave. It is in the adobe livedocs at soundmixer . My problem is how to widen up the sound wave? For example I would like it to be 655 pixels. I can change it to draw to different channels and also change the height of the drawing but cannot find how to change the width of the whole drawing
Any idea how to do that?
Thanks.
package {
import flash.display.Sprite;
import flash.display.Graphics;
import flash.events.Event;
import flash.media.Sound;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.utils.ByteArray;
import flash.text.TextField;
public class SoundMixer_computeSpectrumExample extends Sprite {
public function SoundMixer_computeSpectrumExample() {
var snd:Sound = new Sound();
var req:URLRequest = new URLRequest("Song1.mp3");
snd.load(req);
var channel:SoundChannel;
channel = snd.play();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
channel.addEventListener(Event.SOUND_COMPLETE, onPlaybackComplete);
}
private function onEnterFrame(event:Event):void {
var bytes:ByteArray = new ByteArray();
const PLOT_HEIGHT:int = 25;
const CHANNEL_LENGTH:int = 256;
SoundMixer.computeSpectrum(bytes, false, 0);
var g:Graphics = this.graphics;
g.clear();
g.lineStyle(0, 0x6600CC);
g.beginFill(0x6600CC);
g.moveTo(0, PLOT_HEIGHT);
var n:Number = 0;
for (var i:int = 0; i < CHANNEL_LENGTH; i++) {
n = (bytes.readFloat() * PLOT_HEIGHT);
g.lineTo(i * 2, PLOT_HEIGHT - n);
}
g.lineTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
g.endFill();
g.lineStyle(0, 0xCC0066);
g.beginFill(0xCC0066, 0.5);
g.moveTo(CHANNEL_LENGTH * 2, PLOT_HEIGHT);
for (i = CHANNEL_LENGTH; i > 0; i--) {
n = (bytes.readFloat() * PLOT_HEIGHT);
g.lineTo(i * 2, PLOT_HEIGHT - n);
}
g.lineTo(0, PLOT_HEIGHT);
g.endFill();
}
private function onPlaybackComplete(event:Event):void {
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
}
}
}

change the x factor in your lineTo(x,y) calls.
for example, change:
g.lineTo(i * 2, PLOT_HEIGHT - n);
to something like:
var xfactor:Number = 655/256;
g.lineTo(i * xfactor, PLOT_HEIGHT - n);
since xfactor is fixed, calculate it before you enter your loops (not within them(

Related

Use beginBitmapFill with existing movieclip/shape? (Animate CC)

All the tutorials for using beginBitmapFill seem to center around dynamically drawing an object. Is it possible to simply apply a bitmap fill to an existing shape that's inside a movieclip? I know I can do this manually by selecting the shape and selecting a bitmap in the Color panel.. but is it possible to do it with code? This is what I'm trying and it's not giving errors, but it's also not working:
grl.tops.shapes.graphics.beginBitmapFill(new cubepattern(), null, true, false);
As others have commented, you can use readGraphicsData and drawGraphicsData respectively. It's even not over-complicated. Simply loop through the IGraphicsData of your desired shape, stop as soon as you've found an instance of the GraphicsBitmapFill class, create a new instance with another BitmapFill and finally apply the changes to the original shape.
Well, a picture is worth a thousand words.
Here's an example. This might seem a bit long but there's just a whole lot of code to prepare a shape and load images to be used as bitmap fills.
Set your eyes on the process() function.
package
{
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.Graphics;
import flash.display.Loader
import flash.display.LoaderInfo;
import flash.display.IGraphicsData;
import flash.display.GraphicsBitmapFill;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.net.URLRequest;
import flash.utils.getQualifiedClassName;
public class Main extends Sprite
{
private var bitmapData1:BitmapData;
private var bitmapData2:BitmapData;
private var masterSprite:Sprite = new Sprite();
private var texturesLoaded:int = 0;
private var loader:Loader = new Loader();
public function Main():void
{
if (stage)
init();
else
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
loader.load(new URLRequest("textureA.jpg"));
addChild(masterSprite);
masterSprite.x = masterSprite.y = 200;
}
private function onComplete(event:Event):void
{
switch (texturesLoaded)
{
case 0:
bitmapData1 = Bitmap(LoaderInfo(event.target).content).bitmapData;
loader.load(new URLRequest("textureB.jpg"));
break;
case 1:
bitmapData2 = Bitmap(LoaderInfo(event.target).content).bitmapData;
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onComplete);
drawStar();
process();
}
texturesLoaded++;
}
private function process():void
{
var tempShape:Shape = Shape(masterSprite.getChildAt(0));
var graphicsData:Vector.<IGraphicsData> = tempShape.graphics.readGraphicsData();
for (var a:int = 0; a < graphicsData.length; a++)
{
if (getQualifiedClassName(graphicsData[a]) == "flash.display::GraphicsBitmapFill")
{
var bitmapFill:GraphicsBitmapFill = new GraphicsBitmapFill(bitmapData2);
graphicsData[a] = bitmapFill; break;
}
}
tempShape.graphics.drawGraphicsData(graphicsData);
}
private function drawStar():void
{
var angles:Array = new Array(0, 36, 72, 108, 144, 180, 216, 252, 288, 324, 360);
var innerRadius:int = 40;
var outerRadius:int = 80;
var shape:Shape = new Shape();
shape.graphics.beginBitmapFill(bitmapData1);
shape.graphics.moveTo(0 + Math.cos(angles[a] * (Math.PI / 180)) * outerRadius, 0 + Math.sin(angles[a] * (Math.PI / 180)) * outerRadius);
for (var a:int = 0; a < angles.length; a++)
{
angles[a] -= 90;
if (a % 2 == 0)
{
shape.graphics.lineTo(0 + Math.cos(angles[a] * (Math.PI / 180)) * outerRadius, 0 + Math.sin(angles[a] * (Math.PI / 180)) * outerRadius);
}
else
{
shape.graphics.lineTo(0 + Math.cos(angles[a] * (Math.PI / 180)) * innerRadius, 0 + Math.sin(angles[a] * (Math.PI / 180)) * innerRadius);
}
}
shape.graphics.endFill();
masterSprite.addChild(shape);
}
}
}

ArgumentError: Removing Child from Stage

I am trying to develop a basic Snake game that involves some inverse kinematics and state machines. I'm trying to get it so when the first segment of the snake interacts with a certain "mouse", it disappears. However, when I do, it doesn't work and I end up getting ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
Here's my code:
package
{
import agent.Agent;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
import flash.geom.Point;
public class Main extends Sprite
{
private var Agents:Vector.<Agent>;
private var segments:Array;
private var numSegments:uint = 150;
private var player:Point = new Point (15, 15)
public function Main():void
{
if (stage) init();
else addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event = null):void
{
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
segments = new Array();
for(var i:uint = 0; i < numSegments; i++)
{
var segment:Segment = new Segment (5, 10);
addChild(segment);
segments.push(segment);
}
//updatePoint();
addEventListener(Event.ENTER_FRAME, onEnterFrame);
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
// entry point
graphics.beginFill(0xeeeeee);
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
Agents = new Vector.<Agent>();
addEventListener(Event.ENTER_FRAME, gameloop);
for (var x:int = 0; x < 10; x++)
{
var a:Agent = new Agent();
addChild(a);
Agents.push(a);
a.x = Math.random() * 10;
a.y = Math.random() * 10;
}
stage.addEventListener(MouseEvent.CLICK, createAgent);
}
private function createAgent(e:MouseEvent):void
{
var a:Agent = new Agent();
stage.addChild(a);
Agents.push(a);
a.x = mouseX;
a.y = mouseY;
}
private function gameloop(e:Event):void
{
for each (var a: Agent in Agents) {
a.update();
trace ("Follow me on Twitter.");
for each(var target: Segment in segments)
{
if (target.hitTestPtarget.x, a.y + target.y, true))
{
stage.removeChild(a);
}
}
}
}
private function onEnterFrame(event:Event):void
{
drag(segments[0], player.x, player.y);
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDown);
for(var i:uint = 1; i < numSegments; i++)
{
var segmentA:Segment = segments[i];
var segmentB:Segment = segments[i - 1];
drag(segmentA, segmentB.x, segmentB.y);
}
}
private function keyDown (evt: KeyboardEvent): void {
//87=w 68=d 83=s 65=a
if (evt.keyCode == 87)
{
player.y-=50;
}
else if (evt.keyCode == 83)
{
player.y+=50;
}
else if (evt.keyCode == 68)
{
player.x+=50;
}
else if (evt.keyCode == 65)
{
player.x-=50;
}
trace (player.x + " " + player.y);
}
private function drag(segment:Segment, xpos:Number, ypos:Number):void
{
var dx:Number = xpos - segment.x;
var dy:Number = ypos - segment.y;
var angle:Number = Math.atan2(dy, dx);
segment.rotation = angle * 180 / Math.PI;
var w:Number = segment.getPin().x - segment.x;
var h:Number = segment.getPin().y - segment.y;
segment.x = xpos - w;
segment.y = ypos - h;
}
}
}
I have tried looking at other posts with the same topic, but I just don't understand what I'm doing wrong. Any help would be greatly appreciated!
You are adding Agents and Segments locally (in Main) and later you are trying to remove them from the stage (which is the top level of the swf and is an another display object).
Either do stage.addChild(...) in your init function or (this is a better option imo) replace stage.removeChild(...) with a removeChild(...) everywhere else - this will keep the objects in a local Main space (who knows, maybe you would want to move around your Main later, make everything invisible at once etc).

How to make a movieClip move independent of the stage if added on it?

In my flash-made game, if my character jump on top of an enemy movieclip it spawns 3 minions from another class by MovieClip(root).addChild(spawn1);. In my minions class I've put the code for them to fall and stop upon hitting the ground and also follow my character.
I have a VCam(virtual camera) movieClip to follow my character(who moves on the stage, not the stage around him) with this code build-in:
import flash.events.Event;
import flash.geom.Matrix;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.display.MovieClip;
//VCam
addEventListener(Event.ENTER_FRAME, handleEnterFrame);
function handleEnterFrame(event:Event):void {
if (parent) {
parent.scaleX = 1 / scaleX;
parent.scaleY = 1 / scaleY;
if (rotation == 0) {
parent.x = (width / 2 - x) / scaleX;
parent.y = (height / 2 - y) / scaleY;
parent.rotation = 0;
} else {
var bounds:Rectangle = getBounds(this);
var angle:Number = rotation * Math.PI / 180;
var midX:Number = -x / scaleX;
var midY:Number = -y / scaleY;
var rx:Number = -bounds.width / 2;
var ry:Number = -bounds.height / 2;
var cos:Number = Math.cos(angle);
var sin:Number = Math.sin(angle);
var rotatedX:Number = rx * cos - ry * sin;
var rotatedY:Number = ry * cos + rx * sin;
var cornerX:Number = midX - rotatedX;
var cornerY:Number = midY - rotatedY;
cos = Math.cos(-angle);
sin = Math.sin(-angle);
parent.x = cornerX * cos - cornerY * sin;
parent.y = cornerY * cos + cornerX * sin;
parent.rotation = -rotation;
}
}
}
addEventListener(Event.REMOVED, handleRemoved, false, 0, true);
function handleRemoved(event:Event):void
{
removeEventListener(Event.ENTER_FRAME, handleEnterFrame);
removeEventListener(Event.REMOVED, handleRemoved);
}
When I jump with my character it seems that the minions follow the movement of my vcam and not behaving normally, jumping with the camera and falling throu'the ground when the character falls.
If I add a child normally from the main timeline by addChild(m_clip); it does not behave like that.
Is there an easy fix? Thanks!
This is the minions class code:
package {
import flash.display.*;
import flash.events.*;
public class EnemySpawned extends MovieClip {
protected var gravitysp: Number = 1;
protected var ySpeedsp: Number = 0;
protected var Speedsp: Number = 6.5;
var charMTL:MovieClip;
public function EnemySpawned()
{
this.addEventListener(Event.ENTER_FRAME, movement);
trace('exist');
}
function movement(event:Event):void
{
var MTL:MovieClip = MovieClip(root);
charMTL = MTL.char1;
ySpeedsp += gravitysp;
if(! MTL.ground_1.hitTestPoint(this.x, this.y, true))
{
this.y += ySpeedsp;
}
if(ySpeedsp > 40)
{
ySpeedsp = 40;
}
for(var j:int = 0; j<20; j++)
{
if(MTL.ground_1.hitTestPoint(this.x, this.y, true))
{
this.y--
ySpeedsp = 0;
}
}
var Distance:Number = charMTL.x - this.x;
if(Distance < -charMTL.width/2 - this.width/2)
{
this.x -= Speedsp;
}
if(Distance > charMTL.width/2 + this.width/2)
{
this.x += Speedsp;
}
}
}
}
There is no moving of ground_1 movieClip via code.

Moving b2body With Keyboard

I have this code that gives the b2Body an impulse towards the cursor when you click on stage.
private function clicked(e:MouseEvent):void
{
var impulse_x:Number = (mouseX / world_scale - mainChar.GetPosition().x);
var impulse_y:Number = (mouseY / world_scale - mainChar.GetPosition().y);
var impulse:b2Vec2 = new b2Vec2(impulse_x, impulse_y);
mainChar.ApplyImpulse(impulse, mainChar.GetPosition());
}
I was trying to use keyboard right arrow key for movement and so in the update function I added the if key[Keyboard.RIGHT]:
private function update(e:Event):void {
world.Step (1 / 30, 10, 10);
if (key[Keyboard.RIGHT]) {
impulse_x = 3;
mainChar.ApplyImpulse(impulse, mainChar.GetPosition());
}
}
private function onKeyUp(e:KeyboardEvent):void
{
key[e.keyCode] = false;
}
private function onKeyDown(e:KeyboardEvent):void
{
key[e.keyCode] = true;
}
But the b2body goes to top left on the screen and stays there and doesn't move. I am changing the impulse value that then goes into the vector that is applied to the body.
Although it doesn't give me any errors.
EDIT: The whole code!
package
{
import Box2D.Collision.Shapes.b2PolygonShape;
import Box2D.Common.Math.b2Vec2;
import Box2D.Dynamics.b2Body;
import Box2D.Dynamics.b2BodyDef;
import Box2D.Dynamics.b2FixtureDef;
import Box2D.Dynamics.b2World;
import Box2D.Dynamics.Contacts.b2ContactEdge;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.MouseEvent;
import flash.ui.Keyboard;
public class Main extends Sprite
{
public var world:b2World = new b2World(new b2Vec2(0, 0), true);
public var world_scale:Number = 30;
public var mainChar:b2Body;
private var ground:b2Body;
public var keys:Array = [];
public var beingPressed:Boolean;
public var impulse_x:Number;
public var impulse_y:Number;
public var impulse:b2Vec2 = new b2Vec2(impulse_x, impulse_y);
public function Main():void
{
createMainCharacter(stage.stageWidth / 2, stage.stageHeight / 2, 50, 100);
var th:uint = 10;
addEventListener(Event.ENTER_FRAME, update);
//stage.addEventListener(MouseEvent.CLICK, clicked);
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
}
/**private function clicked(e:MouseEvent):void
{
var impulse_x:Number = (mouseX / world_scale - mainChar.GetPosition().x);
var impulse_y:Number = (mouseY / world_scale - mainChar.GetPosition().y);
var impulse:b2Vec2 = new b2Vec2(impulse_x, impulse_y);
mainChar.ApplyImpulse(impulse, mainChar.GetPosition());
}**/
private function update(e:Event):void
{
world.Step (1 / 30, 10, 10);
var temp:Sprite;
for (var body:b2Body = world.GetBodyList(); body != null; body = body.GetNext())
{
if (body.GetUserData())
{
temp = body.GetUserData() as Sprite;
temp.x = body.GetPosition().x * world_scale;
temp.y = body.GetPosition().y * world_scale;
temp.rotation = body.GetAngle() * (180 / Math.PI); // radians to degrees
}
}
if (keys[Keyboard.RIGHT])
{
impulse_x = 3;
impulse_y = 0;
mainChar.ApplyImpulse(impulse, mainChar.GetPosition());
} else {
impulse_x = 0;
impulse_y = 0;
}
}
private function createMainCharacter(x:Number, y:Number, width:Number, height:Number):void
{
var mainCharSprite:Sprite = new Sprite();
mainCharSprite.graphics.beginFill(0x000000);
mainCharSprite.graphics.drawRect( -width / 2, -height / 2 , width, height);
mainCharSprite.graphics.endFill;
mainCharSprite.x = x;
mainCharSprite.y = y;
addChild(mainCharSprite);
var mainCharDef:b2BodyDef = new b2BodyDef();
mainCharDef.userData = mainCharSprite;
mainCharDef.type = b2Body.b2_dynamicBody;
mainCharDef.position.Set (x / world_scale, y / world_scale);
mainChar = world.CreateBody(mainCharDef);
var shape:b2PolygonShape = new b2PolygonShape();
shape.SetAsBox((width / 2) / world_scale, (height / 2) / world_scale);
var fixtureDef:b2FixtureDef = new b2FixtureDef();
fixtureDef.shape = shape;
fixtureDef.restitution = 0.1;
fixtureDef.friction = 0.1;
fixtureDef.density = 0.5;
mainChar.CreateFixture(fixtureDef);
}
private function onKeyUp(e:KeyboardEvent):void
{
keys[e.keyCode] = false;
}
private function onKeyDown(e:KeyboardEvent):void
{
keys[e.keyCode] = true;
}
}
}
Changing the values of impulse_x and impulse_y is not going to update the values used by the b2Vec2 impulse. In AS3 primitives are passed by value not by reference. If you want the b2Vec2 object referenced by the variable impulse to change its values you need to change them directly on the object itself:
impulse.x = 3.0;
impulse.y = 0.0;
mainChar.ApplyImpulse(impulse, mainChar.GetPosition());

as3 greensock throwprops in function use any MC

I am using greescock code for as3 and I simply want to annimate a movie from a class. The movie is called content in the About class where this code it.
As you can see my content is called "content" and I am replacing the mc var here with content. Hoping this would work but nothing.
Any ideas how to use Greensock as3 and how to scroll content?
var mc:Sprite = getChildByName("content") as MovieClip;
package com.views
{
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]);
public class viewAbout extends MovieClip
{
public function viewAbout()
{
var bounds:Rectangle = new Rectangle(0,100,1080,1920);
var mc:Sprite = getChildByName("content") as MovieClip;
//setupTextField(mc, bounds);
var blitMask:BlitMask = new BlitMask(mc,bounds.x,bounds.y,bounds.width,bounds.height,false);
var t1:uint,t2:uint,y1:Number,y2:Number,yOverlap:Number,yOffset:Number;
blitMask.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
TweenLite.killTweensOf(mc);
trace("DOWN DOWN mouse");
//blitMask.alpha = .3;
y1 = y2 = mc.y;
yOffset = this.mouseY - mc.y;
yOverlap = Math.max(0,mc.height - bounds.height);
t1 = t2 = getTimer();
mc.stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
mc.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
}
function mouseMoveHandler(event:MouseEvent):void
{
trace("Move Event");
var y:Number = this.mouseY - yOffset;
//if mc's position exceeds the bounds, make it drag only half as far with each mouse movement (like iPhone/iPad behavior)
if (y > bounds.top)
{
trace("Somethign ?");
mc.y = (y + bounds.top) * 0.5;
}
else if (y < bounds.top - yOverlap)
{
mc.y = (y + bounds.top - yOverlap) * 0.5;
}
else
{
mc.y = y;
}
blitMask.update();
var t:uint = getTimer();
//if the frame rate is too high, we won't be able to track the velocity as well, so only update the values 20 times per second
if (t - t2 > 50)
{
y2 = y1;
t2 = t1;
y1 = mc.y;
t1 = t;
}
event.updateAfterEvent();
}
function mouseUpHandler(event:MouseEvent):void
{
trace("UP UP UP! ");
mc.stage.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
mc.stage.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
var time:Number = (getTimer() - t2) / 1000;
var yVelocity:Number = (mc.y - y2) / time;
ThrowPropsPlugin.to(mc, {throwProps:{
y:{velocity:yVelocity, max:bounds.top, min:bounds.top - yOverlap, resistance:300}
}, onUpdate:blitMask.update, ease:Strong.easeOut
}, 10, 0.3, 1);
}
// constructor code
}
}
}
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);
}
}