All pastes #280180 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-15 18:37 UTC
rendered paste body
import mx.utils.Delegate;
setInterval(Delegate.create(this,attachAndAnimate), 800);
var counter = 0;
var hitcounter = 0;
tfScore.text = hitcounter;

function attachAndAnimate()
{
	this.attachMovie ("bunny", "mcBunny" + counter, this.getNextHighestDepth() );

	var mcBunny = this["mcBunny" + counter];

	mcBunny.onPress = function()
	{
		trace("Im hit");
		mcBunny.startDrag();
		tweenDown.onMotionFinished;
		delete tweenUp.onMotionFinished;
	}

	mcBunny.onRelease = function()
	{
		mcBunny.stopDrag();
		this.gotoAndPlay (25);
		trace("up")

		hitcounter = hitcounter + 1;
		
		trace(hitcounter); //was missing a ";". anyway, this traces the hitcounter?
		
		tfScore.text = hitcounter; //this should work.. but try tracing tfScore: trace(tfScore); and see if it prints 
		//out something that says it's a textfield.  if not, then that means there's something wrong not with hitcounter, 
		//but the textfield.  maybe it's not named?

		delete tweenDown.onMotionFinished;

		//animate up
		easeType = mx.transitions.easing.None.easeNone;
		var begin = mcBunny._y;
		var end = 0 - mcBunny._height;
		var time = 3;
		var tweenUp = new mx.transitions.Tween(mcBunny, "_y", easeType, begin, end, time, true);

		tweenUp.onMotionFinished = function()
		{
			mcBunny.removeMovieClip();
		};
	}


	//change the y
	mcBunny._y = 0 - mcBunny._height;

	//change the x
	mcBunny._x = Math.random() * (mcBunny._width);

	//animate down
	easeType = mx.transitions.easing.None.easeNone;
	var begin = mcBunny._y;
	var end = 300;
	var time = 6;
	var tweenDown = new mx.transitions.Tween(mcBunny, "_y", easeType, begin, end, time, true);

	tweenDown.onMotionFinished = function()
	{
		mcBunny.removeMovieClip();
	};

	mcBunny._x = Math.random() * 550 - (mcBunny._width);

	//increment the counter
	counter = counter + 1;
}