Return to Snippet

Revision: 31612
at September 9, 2010 19:43 by jaredyeo


Updated Code
import flash.utils.Timer;
import flash.events.TimerEvent;

var xTime : int = 0;
var xCount : int = 100;
var xHalf : int = xCount / 2;
var xTimer : Timer;

xTimer = new Timer(10);
xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
xTimer.start();

function xfOnTimer(e : TimerEvent) : void
{
	xCount--;

	// for the dramatic finish
	if (xCount < 2)
		xTime += 4000;
	else if (xCount < 5)
		xTime += 200
	else if (xCount < 10)
		xTime += 100;
	else if (xCount < 50)
		xTime += 10
		
	// frame changing
	if (mcContent.currentFrame == mcContent.totalFrames)
		mcContent.gotoAndStop(1);
	else
		mcContent.nextFrame()
	
	// new interval
	xTimer.stop();
	if (xCount != 1)
	{
		xTimer = new Timer(xTime);
		xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
		xTimer.start();
	}
}

Revision: 31611
at September 9, 2010 19:39 by jaredyeo


Updated Code
import flash.utils.Timer;
import flash.events.TimerEvent;

var xTime : int = 0;
var xCount : int = 100;
var xHalf : int = xCount / 2;
var xTimer : Timer;

xTimer = new Timer(10);
xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
xTimer.start();

function xfOnTimer(e : TimerEvent) : void
{
	xCount--;
	
	// for the dramatic finish
	if (xCount < 2)
		xTime += 4000;
	else if (xCount < 5)
		xTime += 200
	else if (xCount < 10)
		xTime += 100;
	else if (xCount < 50)
		xTime += 10
		
	// frame changing
	if (mcContent.currentFrame == mcContent.totalFrames)
		mcContent.gotoAndStop(1);
	else
		mcContent.nextFrame()
	
	// new interval
	xTimer.stop();
	xTimer = new Timer(xTime);
	xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
	xTimer.start();
}

Revision: 31610
at September 9, 2010 19:20 by jaredyeo


Initial Code
import flash.utils.Timer;
import flash.events.TimerEvent;

var xTime : int = 0;
var xCount : int = 100;
var xHalf : int = xCount / 2;
var xTimer : Timer;

xTimer = new Timer(10, 1);
xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
xTimer.start();

function xfOnTimer(e : TimerEvent) : void
{
	xCount--;
	
	// for the dramatic finish
	if (xCount < 2)
		xTime += 4000;
	else if (xCount < 5)
		xTime += 200
	else if (xCount < 10)
		xTime += 100;
	else if (xCount < 50)
		xTime += 10
		
	// frame changing
	if (mcContent.currentFrame == mcContent.totalFrames)
		mcContent.gotoAndStop(1);
	else
		mcContent.nextFrame()
	
	// new interval
	xTimer = new Timer(xTime, 1);
	xTimer.addEventListener(TimerEvent.TIMER, xfOnTimer, false, 0, true);
	xTimer.start();
}

Initial URL
http://simplistika.com/jackpot-slots/

Initial Description

                                

Initial Title
Simple jackpot slot machine script

Initial Tags

                                

Initial Language
ActionScript 3