flash on 2010-4-13
♥0 |
Line 46 |
Modified 2010-04-13 19:43:30 |
MIT License
archived:2017-03-30 02:25:17
ActionScript3 source code
/**
* Copyright kihon ( http://wonderfl.net/user/kihon )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gOts
*/
package
{
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.Loader;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.system.Security;
[SWF(frameRate = 120)]
public class Main extends Sprite
{
private const WIDTH:int = 465;
private const HEIGHT:int = 465;
private var bd:BitmapData;
public function Main()
{
Security.loadPolicyFile("http://farm3.static.flickr.com/crossdomain.xml");
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, initHandler);
loader.load(new URLRequest("http://farm3.static.flickr.com/2047/2280715132_f0a72c1088.jpg"), new LoaderContext(true));
}
private function initHandler(event:Event):void
{
var loader:Loader = event.currentTarget.loader;
var matrix:Matrix = new Matrix();
matrix.scale(WIDTH / loader.width, HEIGHT / loader.height);
bd = new BitmapData(WIDTH, HEIGHT);
bd.draw(loader, matrix);
addChild(new Bitmap(bd));
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
private function onEnterFrame(event:Event):void
{
var copybd:BitmapData = bd.clone();
var tx:int = 2;
bd.scroll(tx, 0);
bd.copyPixels(copybd, new Rectangle(WIDTH - tx, 0, tx, HEIGHT), new Point());
}
}
}