flash on 2009-8-3
/**
* Copyright hacker_4ado7ewu ( http://wonderfl.net/user/hacker_4ado7ewu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/zGDc
*/
package
{
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
import flash.events.MouseEvent;
public class FlashTest extends Sprite {
private var stretch:Number = 20;
private var amp:Number = 50;
private var vx:Number = 0;
private var vy:Number = 0;
private var k:Number = 1;
private var target:Number = 1;
private var spring:Number = .12;
private var friction:Number = .95;
private var oldY:Number = 0;
private var spr:Sprite;
private var smoother:Number;
public function FlashTest()
{
spr = new Sprite;
stage.addEventListener(Event.ENTER_FRAME, onEvery);
addChild(spr);
spr.addEventListener(MouseEvent.MOUSE_OVER, onOver);
}
private function onEvery (e:Event):void
{
//amp = Math.abs(oldY - mouseY);
spr.graphics.clear();
for(var i:uint = 0; i<stage.stageWidth; i++)
{
var yew:Number = Math.sin(i / stretch) * amp;
spr.graphics.beginFill(0x000000);
spr.graphics.drawRect(i + k, 200 + yew, 2, 2);
spr.graphics.endFill();
//amp *= .99;
}
var dy:Number = target - amp;
var ay:Number = dy * spring;
vy += ay; vy *= friction;
amp += vy;
oldY = mouseY;
}
private function onOver(e:MouseEvent):void
{
amp = Math.random() * 50;
}
}
}