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

Visual center-click game! (真ん中クリックゲーム)

mulai 20090323 23:01
selesai 20090323 23:49
48 menit
Get Adobe Flash player
by yuku 23 Mar 2009

    Talk

    makc3d at 08 Oct 2009 01:27
    three tries, 62/110/57 - how? I suppose I should be equally accurate over time? or was I just lucky to get 110

    Tags

    Embed
// mulai 20090323 23:01
// selesai 20090323 23:49
// 48 menit

package {
	import flash.display.Sprite;

	[SWF(width=300, height=400, backgroundColor=0x000000)]
	public class entah5 extends Sprite
	{
		public static var ini
		
		public function entah5()
		{
			ini = this
			addChild(new entah5_())
		}
	}	
}

import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.filters.BlurFilter;
import flash.filters.GlowFilter;
import flash.geom.Point;
import flash.text.TextField;
import flash.text.TextFormat;
import flash.utils.Timer;
import flash.display.Sprite;


class entah5_ extends Sprite {

	var pt: TextField = new TextField
	var atas: Sprite = new Sprite
	var bawah: Sprite = new Sprite
	var aa, bb
	var st: TextField = new TextField
	var nl: TextField = new TextField
	var ga: Sprite
	var n_ = 0
	var u_ = 0
	var abis: TextField = new TextField
	
	public function entah5_()
	{
		addChild(atas)
		
		with(pt) {
			defaultTextFormat = new TextFormat(null, 30)
			autoSize = 'left'
			selectable = false
			mouseEnabled = false
			textColor = 0xaaaaaa;
			htmlText = "klik di <b><font color='#ffdddd'>tengah2</font></b> garis!\n行の<b><font color='#ffdddd'>真ん中</font></b>をクリック!\nclick the line <b><font color='#ffdddd'>center</font></b>!"
		}	
		atas.addChild(pt)
		
		with (st) {
			defaultTextFormat = new TextFormat(null, 20)
			autoSize = 'left'
			selectable = false
			mouseEnabled = false
			visible = false
		}
		atas.addChild(st)

		with (nl) {
			defaultTextFormat = new TextFormat(null, 25, 0x77ff77)
			autoSize = 'right'
			x = 300
			text = '0'
			selectable = false
			mouseEnabled = false
		}
		atas.addChild(nl)

		addChild(bawah)

		lup()
	}
	
	function lup() {
		//if (ga) bawah.removeChild(ga)
		
		mule()
		ga = new Sprite
		gam()
		ga.alpha = 0.7
		ga.buttonMode = true
		bawah.addChild(ga)
		
		ga.addEventListener(MouseEvent.ROLL_OVER, function() {
			ga.alpha = 1.0
		})
		ga.addEventListener(MouseEvent.ROLL_OUT, function() {
			ga.alpha = 0.7
		})
		ga.addEventListener('click', function(e) {
			pt.visible = false
			hit(ga, e.stageX, e.stageY)
			st.visible = true
			var t: Timer = new Timer(1000, 1)
			t.addEventListener(TimerEvent.TIMER, function() {
				st.visible = false
			})
			t.start()
			ga.removeEventListener('click', arguments.callee)
			sing(ga)
			u_++
			if (u_ >= 10) GO() 
			else lup()
		})
	}
	
	function GO() {
		removeChild(atas)
		removeChild(bawah)
		
		addChild(abis)
		with(abis) {
			scaleX = scaleY = 4
			defaultTextFormat = new TextFormat(null, 50)
			autoSize = 'center'
			selectable = false
			buttonMode = true
			y = 35
			x = 150
			textColor = 0xe9e9e9;
			text = nl.text
		}
		
		var t: Timer = new Timer(30)
		var ini = this
		t.addEventListener(TimerEvent.TIMER, function() {
			var w = t.currentCount % 30
			if (w > 15) w = 30-w
			abis.filters = [new GlowFilter(0x88ffff, 1, w, w)] 
                        stage.addEventListener('click', function() {
			    t.stop()
                            stage.removeEventListener('click', arguments.callee)
        			entah5.ini.removeChild(ini)
        			entah5.ini.addChild(new entah5_())
	        	})
		})
		t.start()
		
		
	}
	function sing(ga) {
		var t: Timer = new Timer(30, 10)
		t.addEventListener('timer', function() {
			ga.filters = [new BlurFilter(t.currentCount*2, t.currentCount*2)]
		})
		t.addEventListener(TimerEvent.TIMER_COMPLETE, function() {
			bawah.removeChild(ga)
		})
		t.start()
	}
	
	function hit(ga, x, y) {
		var tx = (aa.x+bb.x)/2
		var ty = (aa.y+bb.y)/2
		var j = new Point(tx-x, ty-y).length
		if (j < 2) {
			st.htmlText = "<font color='#88ff00'>TEPAT!\nあったり!\nHIT!</font>"
			skor(10 + (10 - j*j*j))
		} else {
			st.htmlText = "<font color='#b89999'><font color='#ccddcc'>" + Math.round(j) + "</font>px meleset/外れ/miss</font>"
			skor((10 - j)/2)
		}
with (ga.graphics) {
    beginFill(0xffffff)
    drawCircle(tx, ty, 3)
    endFill()
    }
	}
	
	function skor(t) {
		if (t<0) t=0
		n_ += int(t)
		nl.text = String(n_)
	}
	
	function mule() {
		aa = new Point(int(Math.random()*250)+50, int(Math.random()*350)+25)
		while (1) {
			bb = new Point(int(Math.random()*250)+25, int(Math.random()*350)+25)
			if (new Point(aa.x - bb.x, aa.y - bb.y).length > 100) break
		}
	}
	
	function gam() {
		with (ga.graphics) {
			clear()
			lineStyle(3.5, 0xaabbff)
			moveTo(aa.x, aa.y)
			lineTo(bb.x, bb.y)
		}
	}
}