All pastes #564870 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-06-13 19:30 UTC
rendered paste body
var coll:Array;
var index:int;
var dynpos:int = 0;
var timer:Timer = new Timer(25);

_up_.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
_up_.addEventListener(MouseEvent.MOUSE_UP, onMRelease);
timer.addEventListener(TimerEvent.TIMER, onTimer);

function onDown(e:MouseEvent):void
{
	timer.start();
}

function onMRelease(e:MouseEvent):void
{
	timer.stop();
	dynpos = 0;
}

function onTimer(e:TimerEvent):void
{
	dynpos++;
	for(var i:int = 0; i< coll.length; i++)
	{
		coll[i].y += dynpos;
		trace(coll[i]);
	}
}

function init():void 
{
	coll = new Array();
	index = 0;
	dynpos = 0;
}

init();

function addcollItem(itm:collItem):void
{
	if(coll == null)
		init();
		
	var posv:int = getVPos();
	coll[index++] = itm;
	itm.y = posv;
	
	addChild(itm);
}

function getVPos():int
{
	if(coll.length == 0)
		return 0;
		
	return (coll[0].getHeight() * coll.length) - 1;
}