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

forked from: forked from: テトリスver0.11

Copyright asfgu ( http://wonderfl.net/user/asfgu )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/1wWa

  ここで使用しているコードはPoisonCodeさんのところで紹介されている物を
  引用させていただいています
  PoisonCode→http://poisoncode.blog77.fc2.com/

サブクラス描画がうまくいきません
メインの書き方が間違っているのでしょうか?
Get Adobe Flash player
by asfgu 22 May 2010
/**
 * Copyright asfgu ( http://wonderfl.net/user/asfgu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/uAwf
 */

// forked from asfgu's forked from: テトリスver0.11
// forked from asfgu's テトリスver0.11
/**
 * Copyright asfgu ( http://wonderfl.net/user/asfgu )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/1wWa
 */

/*
  ここで使用しているコードはPoisonCodeさんのところで紹介されている物を
  引用させていただいています
  PoisonCode→http://poisoncode.blog77.fc2.com/
*/
/*
  サブクラス描画がうまくいきません
  メインの書き方が間違っているのでしょうか?
*/

package {
	import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.geom.Point;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.ui.Keyboard;
    import flash.utils.Timer;
    import flash.events.TimerEvent;

       [SWF(width="500", height="400", backgroundColor="0x45b482", frameRate="30")]
	   
	   public class Main extends Sprite {
	   	
		   private var tetris_left:Tetris;
		   //private var tetris_right:Tetris;
		   private var base:Sprite = new Sprite;
		   
		   public function Main() {
			   tetris_left = new Tetris();
			   //tetris_right = new Tetris();
			   //addChild(base);
			   addChild(base);
			   base.addChild(tetris_left);
			   
        if(base.contains(tetris_left)){
        		var canvas:Sprite = new Sprite();
        		canvas.x = 100;
        		canvas.y = 100;
        		canvas.graphics.beginFill(0x0);
			canvas.graphics.drawCircle(0, 0, 100);
			canvas.graphics.endFill();
			base.addChildAt(canvas,1);
        }
        
		   }
   }  
}

	import flash.display.Sprite;
    import flash.display.Shape;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.geom.Point;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;
    import flash.ui.Keyboard;
    import flash.events.MouseEvent;
    import flash.utils.Timer;
    import flash.events.TimerEvent;
   
    class Tetris extends Sprite {
    	private var canvas:Sprite;
	public function Tetris() {
		draw();
		addEventListener(MouseEvent.CLICK, clicked);
	}
	private function clicked(e:MouseEvent) : void {
		removeChild(canvas);
		draw();
	}
	private function draw() : void {
		canvas = new Sprite();
		canvas.graphics.beginFill(Math.random() * 0xffffff);
		canvas.graphics.drawCircle(500 * Math.random(), 500 * Math.random(), 100);
		canvas.graphics.endFill();
		addChild(canvas);
	}
    }