forked from: flash on 2010-5-1
/**
* Copyright 9re ( http://wonderfl.net/user/9re )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aXC8
*/
// forked from 9re's flash on 2010-5-1
package {
import flash.display.Sprite;
import net.hires.debug.Stats;
import flash.events.Event;
import flash.display.BitmapData;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.text.TextField;
public class FlashTest extends Sprite {
private var _count:int = 0;
private var _tf:TextField;
public function FlashTest() {
// write as3 code here..
addChild(new Stats);
_tf = new TextField;
_tf.y = 100;
addChild(_tf);
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, timerHandler);
timer.start();
}
private function timerHandler(e:TimerEvent):void {
var bd:BitmapData = new BitmapData(800, 800);
var bd2:BitmapData = new BitmapData(10, 100);
stage.addEventListener(MouseEvent.CLICK, bind(useBitmapData, bd2));
_tf.text = ++_count + '';
_tf.width = _tf.textWidth + 4;
_tf.height = _tf.textHeight + 4;
}
private function bind(func:Function, ...args:Array):Function {
return function (e:Event):void {
e.currentTarget.removeEventListener(e.type, arguments.callee);
func.apply(null, args.concat(e));
};
}
private function useBitmapData(bd:BitmapData, e:Event):void {
_tf.text = --_count + '';
_tf.width = _tf.textWidth + 4;
_tf.height = _tf.textHeight + 4;
bd.clone();
}
}
}