In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2010-3-9

Get Adobe Flash player
by meat18 15 Mar 2010

    Talk

    Oghel at 12 Apr 2012 17:07
    Hello, you did exactly what I wanted to produce, and I'd like to use your code in a bigger project. But I can't success in using your code :-( I've started using as3 not so long ago so i'm sorry if this question sounds a bit silly ^^ I created a fla, linked to your class, then I declared in this fla a variable like this : import wuTj; var wuwu : Sample20091109 = new Sample20091109(); but it doesn't work of course. Can someone explain me how to use it ?
    Embed
package {
	import flash.display.*;
	import flash.events.*;
	import flash.filters.BlurFilter;
	import flash.geom.*;
	public class Sample20091109 extends Sprite {
		private var _ball:Ball; 
		private var _canvas:BitmapData;
		private var _world:Sprite;
		private var _sp:Sprite = new Sprite;
		private var _startBtn:StartBtn;
		public function Sample20091109():void{
			stage.scaleMode=StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;
			var g:Graphics = _sp.graphics;
			g.beginFill(0xFF0000);
			g.moveTo(-4,50);
			g.lineTo(-4,20);
			g.lineTo(4,20);
			g.lineTo(4,50);
			_init();
		}
		
		private function _init():void {
			
			_startBtn = new StartBtn();
			addChild(_startBtn);
			_startBtn.x = stage.stageWidth / 2 - _startBtn.width / 2;
			_startBtn.y = stage.stageHeight / 2 - _startBtn.height / 2;  
			_startBtn.addEventListener(MouseEvent.MOUSE_DOWN, _startHandler);  
			
		}
		
		private function _startHandler(e:MouseEvent):void {
			
			removeChild(_startBtn);
			
			_canvas = new BitmapData( stage.stageWidth,  stage.stageHeight, true, 0xFFFFFF);  
			addChild(new Bitmap(_canvas)) as Bitmap;
			
			_world = new Sprite();
			_world.addChild(_sp);
			_sp.x = 200;
			_sp.y = 200;
			
			this.stage.addEventListener(Event.ENTER_FRAME, _enterframeHandler);  
			
		}
		
		private function _enterframeHandler(e:Event):void {
			_canvas.lock();  
			_canvas.applyFilter( _canvas, _canvas.rect, new Point(), new BlurFilter(5,5,2));   
			_canvas.colorTransform(_canvas.rect, new ColorTransform(1,1,1,1,0,0,0,-10));   
			_canvas.draw( _world, null, null,BlendMode.ADD);
			_sp.rotation += 10;
			_canvas.unlock();
			
		}
	}  
}  
  
import flash.display.Sprite;   
   
class Ball extends Sprite {  
      
    public function Ball():void {  
          
        this.graphics.beginFill(0xCC0000);  
        this.graphics.drawCircle(0, 0, 30);  
        this.graphics.endFill();  
          
    }  
      
}  
  
import flash.display.Sprite;   
import flash.text.TextField;  
import flash.text.TextFormat;  
import flash.text.TextFieldAutoSize;  
import flash.text.TextFormatAlign;  
   
class StartBtn extends Sprite {  
      
    public function StartBtn():void {  
          
        this.graphics.beginFill(0x666666);  
        this.graphics.drawRect(0,0, 140, 30);  
        this.graphics.endFill();  
  
        this.buttonMode = true;  
        this.mouseChildren = false;  
          
        var tf:TextField = new TextField();  
        tf.width = 140;  
        tf.autoSize = TextFieldAutoSize.CENTER; //autoSizeを指定しないと高さが100pxになる  
        tf.y = 4;  
        tf.selectable=false;  
        this.addChild(tf);  
              
        var format:TextFormat=new TextFormat();  
        format.color=0xFFFFFF;  
        format.size = 14;  
        format.bold = true;  
        tf.defaultTextFormat = format;  
        tf.text = "S T A R T";  
          
    } 
}