forked from: massmedian challenge
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/41QZ
*/
// forked from 9re's forked from: massmedian challenge
// forked from checkmate's massmedian challenge
package {
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.net.*;
import flash.system.LoaderContext;
public class Begineer extends Sprite{
//-------------------------------//
// Use properties as follows.
//-------------------------------//
private var _sliceList:Array;
private var _v:Number = 10;
private var _x:Number = -3;
private var _vy:Number = -10;
private var _y:Number = 2;
private var _c:Number = 0.007;
private var _cy:Number = 0.009;
private var _vs:Number = 0.08;
private var _xs:Number = -0.01;
private var _cs:Number = 0.002;
//-------------------------------//
// Change functions as follows.
//-------------------------------//
public function updateEnterFrame( e:Event ):void{
_v -= _x * _c;
_x += _v;
_vy -= _y * _cy;
_y += _vy;
_vs -= _xs * _cs;
_xs += _vs;
var slice:DisplayObject = _sliceList[0];
var part:DisplayObject;
slice.y = _x - mouseY * 0.5 + 300;
slice.x = _y - mouseX * 0.5 + 300;
slice.scaleY = _xs;
var len:int = _sliceList.length;
for each (part in _sliceList) {
part.y += (slice.y - part.y) * 0.9;
part.x += (slice.x - part.x) * 0.9;
part.scaleY += (slice.scaleY - part.scaleY) * 0.85;
slice = part;
}
}
//-------------------------------//
// Do not change following codes.
//-------------------------------//
public function Begineer(){
var ctxt :LoaderContext = new LoaderContext(true);
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener( Event.COMPLETE, onLoadComplete );
loader.load( new URLRequest("http://swf.wonderfl.net/static/assets/massmedian.png"), ctxt );
}
public function onLoadComplete(e:Event):void {
var loader:Loader = LoaderInfo( e.target ).loader;
loader.contentLoaderInfo.removeEventListener( Event.COMPLETE, onLoadComplete );
var bitmapdata:BitmapData = new BitmapData( loader.width, loader.height, true, 0xFF0000 );
bitmapdata.draw( loader );
_sliceList = sliceBanner( bitmapdata, bitmapdata.width );
addEventListener( Event.ENTER_FRAME, updateEnterFrame );
}
private function sliceBanner( banner:BitmapData, length:int = 100 ):Array{
var sliceList:Array = [];
var w:int = Math.floor( banner.width/length );
var h:int = Math.floor( banner.height );
var t:int = Math.ceil( banner.width - w*length );
var mat:Matrix = new Matrix();
for( var i:int = 0; i<length; i++ ) {
var bmpd :BitmapData = new BitmapData( w, h, true, 0xFFFF00 );
mat.tx = -w*i;
bmpd.draw( banner, mat );
var part:DisplayObject = addChild( new Bitmap( bmpd ) );
part.x = w*i;
sliceList.push( part );
}
return sliceList;
}
}
}