﻿// Copyright 2007. Adobe Systems Incorporated. All Rights Reserved.
package com.adobe.captivate.events 
{
	import flash.events.Event;

	/**
	 * The CPVariableValueChangedEvent class describes the event object passed to the event listener when a captivate variable is changed
	 */
	public class CPVariableValueChangedEvent extends CaptivateEvent 
	{
	/**
		*  The <code>CPVariableValueChangedEvent.CPVARIABLEVALUECHANGEDEVENT</code> constant defines the value of the
		*  <code>type</code> property of the event object for an <code>CPMoviePauseEvent</code> event.
		*  <p>The properties of the event object have the following values:</p>
		*  <table class="innertable">
		*     <tr><th>Property</th><th>Value</th></tr>
		*     <tr><td><code>bubbles</code></td><td><code>true</code></td></tr>
		*     <tr><td><code>variableNamesArray</code></td><td>Array of Name of the variables being changed</td></tr>
		*     <tr><td><code>oldValue</code></td><td>The slide number of the slide in which the movie is paused</td></tr>
		*     <tr><td><code>newValue</code></td><td>The frame number upon which the movie is paused</td></tr>
		*	  </table>
		*  @eventType CPVariableValueChangedEvent	
		*/
		public static const CPVARIABLEVALUECHANGEDEVENT:String = "CPVariableValueChangedEvent";
		public static const CPSPECIFICVARIABLEVALUECHANGEDEVENT_PREPENDER:String = "CHANGED_";
		/**
		* @private
		*/
		private var m_OldValue:Object;
		/**
		* @private
		*/
		private var m_NewValue:Object;
		/**
		* @private
		*/
		private var m_VariableNamesArray:Array;
		
		private var m_EventType:String;
		
		public function CPVariableValueChangedEvent(aEventType:String,captivateVersion:String="",aVarNamesArray:Array = null,aOldValue:Object=null,aNewValue:Object=null) 
		{
			m_EventType = aEventType;
			var lEventType:String = aEventType;
			if(lEventType.length)
			{
				lEventType = CPSPECIFICVARIABLEVALUECHANGEDEVENT_PREPENDER + aEventType;
			}
			else
			{
				lEventType = CPVARIABLEVALUECHANGEDEVENT;
			}	
			super(lEventType,captivateVersion,false,false);
			m_VariableNamesArray = aVarNamesArray;
			m_OldValue = aOldValue;
			m_NewValue = aNewValue;
		}
		/**
		* @private
		*/
		public override function clone():Event
		{
			return new CPVariableValueChangedEvent(m_EventType,captivateVersion,variableNamesArray,oldValue,newValue);
		}
		/**
		* The name of the variable being changed
		*/
		public function get variableNamesArray():Array
		{
			return m_VariableNamesArray;
		}
		
		/**
		* The name of the variable being changed
		*/
		public function set variableNamesArray(aVarNamesArray:Array):void
		{
			m_VariableNamesArray = aVarNamesArray;
		}
		
		/**
		* The old value of the variable
		*/
		public function get oldValue():Object
		{
			return m_OldValue;
		}
		
		public function set oldValue(aVal:Object):void
		{
			m_OldValue = aVal;
		}
		
		/**
		* The new value of the variable
		*/
		public function get newValue():Object
		{
			return m_NewValue;
		}
		
		public function set newValue(aVal:Object):void
		{
			m_NewValue = aVal;
		}
		/**
		* @private
		*/
		public override function toString():String
		{
			return formatToString("CPVariableValueChangedEvent","type","bubbles","cancelable","eventPhase","captivateVersion","variableNamesArray","oldValue","newValue");
		}
	}
}
