All pastes #208878 Raw Edit

Unnamed

public text v1 · immutable
#208878 ·published 2006-10-18 21:28 UTC
rendered paste body
/**
 * @author Alp
 */

import com.dynamicflash.utils.Delegate;
import com.flashweek.TestClip;

class com.abusive.TOTI {
	
	private var words:Array = new Array(
		"Wort1", "Wort2", "Wort3"
	);

	private var scope:MovieClip;
	var linkedClip:MovieClip;

	static var yStart = -16;
	var y = yStart;
	
	function TOTI(target:MovieClip) {
	
		scope = target;
		
		// --- Creates a 'tf' TextField size 100x600 at pos 100, 100
		scope.createTextField("tf", 0, 100, y, 800, 600);
	
		// --- Write some text into it
		scope.tf.text = getRandomWord();
		
		// --- Creates a 'ti' TextInput size 100x600 at pos 100, 100
		scope.createTextInput("ti", 0, 100, y, 800, 600);
	
		// --- Dynamic MovieClip linkage
		linkedClip = scope.attachMovie(TestClip.SymbolName, "testClip_inst", 1);
		linkedClip._x = 200;
		linkedClip._y = 200;
		linkedClip._rotation = 30;
		linkedClip._alpha = 70;

		//local function: drawPoint
		var drawPoint = function(p:flash.geom.Point, size:Number, tgt:MovieClip, color: Number){
			if (!color) color = 0x000000; //black
			tgt.lineStyle(size, color);
			tgt.moveTo(p.x-1, p.y);
			tgt.lineTo(p.x+1, p.y);
			tgt.moveTo(p.x, p.y-1);
			tgt.lineTo(p.x, p.y+1);
		}
		
		//Draw a diagonal line of Points 10 pixels apart
		for(var i = 10; i < 200; i += 10){
			var myPoint = new flash.geom.Point(i,i);
			drawPoint(myPoint, 5, scope);
		}
		
		//assign event handler
		scope.onEnterFrame = Delegate.create(this, handleEnterFrame);
	}
	
	function getRandomWord() {
		return words[rand(0,words.length - 1)];
	}
		
	function rand(min:Number, max:Number):Number {
	    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
	    return randomNum;
	}	
	
	public function handleEnterFrame() {
		if(y > 300) {
			y = yStart;
			scope.tf.text = getRandomWord();
		}	
		y += 1;
		scope.tf._y = y;
		
		linkedClip._rotation = rand(20, 30);
	}
	
	// --- Main Entry Point
	static function main() {		
		var test:TOTI = new TOTI(_root);
		trace("test 1!");
	}
}