﻿	
	// JavaScript Document
	// Animation v01
	// Ailantd & Additive Works 
	// www.ailantd.com & www.additiveworks.com

	var oAnimation = new CAnimation( 40 );
	oAnimation.Play();

	// Animation()
	//------------------------------------------------------------
	//
	// METODOS
	//------------------------------------------------------------
	// Play()
	// Pause()
	//------------------------------------------------------------	
	function CAnimation( nFps )
	{		
		this._oTimer;
		this._nFps 	= 1000/nFps;
		//------------------------------------------
		// METHODS
		//------------------------------------------

		// PLAY
		//
		// ---------------------------------------------------------------------- 
		this.Play = function()
		{
			if( this._oTimer ) clearInterval( this._oTimer );
			this._oTimer = setInterval( "oEvent.Throw('onFrame')" , this._nFps );
		}
		
		// STOP
		//
		// ---------------------------------------------------------------------- 		
		this.Stop = function()
		{
			if( this._oTimer ) clearInterval( this._oTimer );
		}

		// SET FPS
		//
		// ---------------------------------------------------------------------- 		
		this.SetFps = function( nFps )
		{
			this._nFps 	= 1000/nFps;
			if( this._oTimer ) clearInterval( this._oTimer );
			this._oTimer = setInterval( "oEvent.Throw('onFrame')" , this._nFps );
		}
	}
