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

ブロック崩し ver 0.00002(制作中)

Get Adobe Flash player
by paq 11 Feb 2009
    Embed
package {
	import flash.display.*;
        import org.libspark.thread.Thread;
        import org.libspark.thread.EnterFrameThreadExecutor;
	
        [ SWF( width = "465" , height = "465" , backgroundColor = "0xFFFFFF" , frameRate = "60" ) ]

	public class Main extends Sprite{

		public function Main():void {
                        Thread.initialize(new EnterFrameThreadExecutor());
			
			var main:MainThread = new MainThread(this);
			main.start();
		}
	}
}


import flash.display.*;
import flash.text.*;
import flash.net.*;

import org.libspark.thread.Thread;
import org.libspark.thread.threads.tweener.TweenerThread;
import org.libspark.thread.utils.*;
import org.libspark.thread.threads.net.URLLoaderThread;

internal class MainThread extends Thread {
	public function MainThread(layer:DisplayObjectContainer) {
		_layer = layer;
	}
	
	private const BAR_W:uint = 100;
	private const BAR_H:uint = 30;
	private const BALL_W:uint = 30;
	private const BALL_H:uint = 30;

	private var _layer:DisplayObjectContainer;
	private var bar:Sprite = new Sprite();
	private var ball:Sprite = new Sprite();
	private var dx:Number = 3,dy:Number = 5;
	private var bounce:Number = -1.02;
	
	//初期処理
	override protected function run():void {
            var g:Graphics = bar.graphics;
            g.beginFill(0x000000);
            g.drawRect(-BAR_W/2, -BAR_H/2, BAR_W, BAR_H);
            g.endFill();
            bar.x = BAR_W/2; bar.y = 465-BAR_H-30;
            _layer.addChild(bar);

            g = ball.graphics;
            g.beginFill(0x000000);
            g.drawRect(-BALL_W/2, -BALL_H/2, BALL_W, BALL_H);
            g.endFill();
            ball.x = 50; ball.y = 50;
            _layer.addChild(ball);

            next(update);
	}

	//
	private function update():void {
            bar.x = _layer.mouseX;

            if (ball.x > 465-BALL_W/2){ ball.x = 465-BALL_W/2;  dx *= bounce;}
            if (ball.y > 465-BALL_H/2){ ball.y = 465-BALL_H/2; dy *= bounce;}
            if (ball.x < BALL_W/2){ ball.x = BALL_W/2; dx *= bounce;}
            if (ball.y < BALL_H/2){ ball.y = BALL_H/2; dy *= bounce;}

            if (ball.hitTestObject(bar)) {
                var a:Number = ball.x - bar.x;
                a = a/10;
                dy = dy / (Math.abs(a) / 2 + 0.8) + 0.2;
                dy *= -2;
                dx += a*1.2;
            }
            if(dx > 7) dx = 7;
            if(dy > 7) dy = 7;
            if(dx < -7) dx = -7;
            if(dy < -7) dy = -7;
            ball.x += dx;
            ball.y += dy;

            next(update);
	}

}