<commit_before>package aerys.minko.scene.controller.animation
{
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.animation.timeline.ITimeline;
	
	import flash.display.BitmapData;
	import flash.utils.getTimer;
	
	/**
	 * The AnimationController uses timelines to animate properties of scene nodes.
	 *  
	 * @author <NAME>
	 * 
	 */
	public class AnimationController extends EnterFrameController implements IAnimationController
	{
		private var _timelines		: Vector.<ITimeline>;
		private var _isPlaying		: Boolean;
		private var _updateOneTime	: Boolean;
		
		private var _loopBeginTime	: int;
		private var _loopEndTime	: int;
		private var _looping		: Boolean;
		private var _currentTime	: int;
		private var _totalTime		: int;
		
		private var _timeFunction	: Function;
		private var _labelNames		: Vector.<String>;
		private var _labelTimes     : Vector.<Number>;
		
		private var _lastTime		: Number;
		
		private var _looped			: Signal;
		private var _started		: Signal;
		private var _stopped		: Signal;
		
		private var _isTimelineUpdateLocked	: Vector.<Boolean>;
		
		public function get numLabels() : uint
		{
			return _labelNames.length;
		}
		
		public function get timeFunction() : Function
		{
			return _timeFunction;
		}
		
		public function set timeFunction(value : Function) : void
		{
			_timeFunction = value;
		}
		
		public function get numTimelines() : uint
		{
			return _timelines.length;
		}
		
		public function get started() : Signal
		{
			return _started;
		}
		
		public function get stopped() : Signal
		{
			return _stopped;
		}
		
		public function get looped() : Signal
		{
			return _looped;
		}
		
		public function get totalTime() : int
		{
			return _totalTime;
		}
		
		public function get looping() : Boolean
		{
			return _looping;
		}
		public function set looping(value : Boolean) : void
		{
			_looping = value;
		}
		
		public function get isPlaying() : Boolean
		{
			return _isPlaying;
		}
		public function set isPlaying(value : Boolean) : void
		{
			_isPlaying = value;
		}
		
		public function get currentTime() : int
		{
			return _currentTime;
		}
		
		public function AnimationController(timelines 	: Vector.<ITimeline>,
											loop		: Boolean	= true)
		{
			super();
			
			initialize(timelines, loop);
		}
		
		private function initialize(timelines 	: Vector.<ITimeline>,
									loop		: Boolean) : void
		{
			_timelines = timelines.slice();
			_looping = loop;
			_labelNames = new <String>[];
			_labelTimes = new <Number>[];
			_looped	= new Signal('AnimationController.looped');
			_started = new Signal('AnimationController.started');
			_stopped = new Signal('AnimationController.stopped');
			
			var numTimelines : uint = _timelines.length;
			
			_isTimelineUpdateLocked	= new Vector.<Boolean>(numTimelines, true);
			for (var timelineId:uint = 0; timelineId < numTimelines; ++timelineId)
			{
				if (_totalTime < _timelines[timelineId].duration)
					_totalTime = _timelines[timelineId].duration;
				
				_isTimelineUpdateLocked[timelineId] = false;				
			}
			
			setPlaybackWindow(0, _totalTime);
			seek(0).play();
		}
		
		public function lockTimelineUpdate(propertyPath	: String)	: void
		{
			changeTimelineUpdateFlag(propertyPath, true);
		}
		
		public function unlockTimelineUpdate(propertyPath	: String)	: void
		{
			changeTimelineUpdateFlag(propertyPath, false);
		}
		
		private function changeTimelineUpdateFlag(propertyPath	: String,
												  isLocked		: Boolean)	: void
		{
			var numTimelines	: uint = _timelines.length;
			for (var timelineId:uint = 0; timelineId < numTimelines; ++timelineId)
				if (_timelines[timelineId].propertyPath == propertyPath)
					_isTimelineUpdateLocked[timelineId] = isLocked ? 1 : 0;
		}
		
		override public function clone() : AbstractController
		{
			var clone : AnimationController = new AnimationController(_timelines.slice(), _looping);
			clone._isTimelineUpdateLocked	= _isTimelineUpdateLocked.slice();
			
			return clone;
		}
		
		public function cloneTimelines() : void
		{
			var numTimelines	: uint	= _timelines.length;
			
			for (var timelineId : uint = 0; timelineId < numTimelines; ++timelineId)
				_timelines[timelineId] = (_timelines[timelineId] as ITimeline).clone();
		}
		
		public function getTimeline(index : uint = 0) : ITimeline
		{
			return _timelines[index];
		}
		
		public function seek(time : Object) : IAnimationController
		{
			var timeValue : uint = getAnimationTime(time);
			
			if (timeValue < _loopBeginTime || timeValue > _loopEndTime)
				throw new Error(
					'Time value is outside of playback window. '
					+'To reset playback window, call resetPlaybackWindow.'
				);
			
			_currentTime = timeValue;
			
			return this;
		}
		<commit_msg>Fixed AnimationController.clone : cloning labels<commit_after>package aerys.minko.scene.controller.animation
{
	import aerys.minko.render.Viewport;
	import aerys.minko.scene.controller.AbstractController;
	import aerys.minko.scene.controller.EnterFrameController;
	import aerys.minko.scene.node.Group;
	import aerys.minko.scene.node.ISceneNode;
	import aerys.minko.scene.node.Scene;
	import aerys.minko.type.Signal;
	import aerys.minko.type.animation.timeline.ITimeline;
	
	import flash.display.BitmapData;
	import flash.utils.getTimer;
	
	/**
	 * The AnimationController uses timelines to animate properties of scene nodes.
	 *  
	 * @author <NAME>
	 * 
	 */
	public class AnimationController extends EnterFrameController implements IAnimationController
	{
		private var _timelines		: Vector.<ITimeline>;
		private var _isPlaying		: Boolean;
		private var _updateOneTime	: Boolean;
		
		private var _loopBeginTime	: int;
		private var _loopEndTime	: int;
		private var _looping		: Boolean;
		private var _currentTime	: int;
		private var _totalTime		: int;
		
		private var _timeFunction	: Function;
		private var _labelNames		: Vector.<String>;
		private var _labelTimes     : Vector.<Number>;
		
		private var _lastTime		: Number;
		
		private var _looped			: Signal;
		private var _started		: Signal;
		private var _stopped		: Signal;
		
		private var _isTimelineUpdateLocked	: Vector.<Boolean>;
		
		public function get numLabels() : uint
		{
			return _labelNames.length;
		}
		
		public function get timeFunction() : Function
		{
			return _timeFunction;
		}
		
		public function set timeFunction(value : Function) : void
		{
			_timeFunction = value;
		}
		
		public function get numTimelines() : uint
		{
			return _timelines.length;
		}
		
		public function get started() : Signal
		{
			return _started;
		}
		
		public function get stopped() : Signal
		{
			return _stopped;
		}
		
		public function get looped() : Signal
		{
			return _looped;
		}
		
		public function get totalTime() : int
		{
			return _totalTime;
		}
		
		public function get looping() : Boolean
		{
			return _looping;
		}
		public function set looping(value : Boolean) : void
		{
			_looping = value;
		}
		
		public function get isPlaying() : Boolean
		{
			return _isPlaying;
		}
		public function set isPlaying(value : Boolean) : void
		{
			_isPlaying = value;
		}
		
		public function get currentTime() : int
		{
			return _currentTime;
		}
		
		public function AnimationController(timelines 	: Vector.<ITimeline>,
											loop		: Boolean	= true)
		{
			super();
			
			initialize(timelines, loop);
		}
		
		private function initialize(timelines 	: Vector.<ITimeline>,
									loop		: Boolean) : void
		{
			_timelines = timelines.slice();
			_looping = loop;
			_labelNames = new <String>[];
			_labelTimes = new <Number>[];
			_looped	= new Signal('AnimationController.looped');
			_started = new Signal('AnimationController.started');
			_stopped = new Signal('AnimationController.stopped');
			
			var numTimelines : uint = _timelines.length;
			
			_isTimelineUpdateLocked	= new Vector.<Boolean>(numTimelines, true);
			for (var timelineId:uint = 0; timelineId < numTimelines; ++timelineId)
			{
				if (_totalTime < _timelines[timelineId].duration)
					_totalTime = _timelines[timelineId].duration;
				
				_isTimelineUpdateLocked[timelineId] = false;				
			}
			
			setPlaybackWindow(0, _totalTime);
			seek(0).play();
		}
		
		public function lockTimelineUpdate(propertyPath	: String)	: void
		{
			changeTimelineUpdateFlag(propertyPath, true);
		}
		
		public function unlockTimelineUpdate(propertyPath	: String)	: void
		{
			changeTimelineUpdateFlag(propertyPath, false);
		}
		
		private function changeTimelineUpdateFlag(propertyPath	: String,
												  isLocked		: Boolean)	: void
		{
			var numTimelines	: uint = _timelines.length;
			for (var timelineId:uint = 0; timelineId < numTimelines; ++timelineId)
				if (_timelines[timelineId].propertyPath == propertyPath)
					_isTimelineUpdateLocked[timelineId] = isLocked ? 1 : 0;
		}
		
		override public function clone() : AbstractController
		{
			var clone : AnimationController = new AnimationController(_timelines.slice(), _looping);
			clone._isTimelineUpdateLocked	= _isTimelineUpdateLocked.slice();
			
			clone._labelNames	= _labelNames.concat();
			clone._labelTimes	= _labelTimes.concat();
			
			return clone;
		}
		
		public function cloneTimelines() : void
		{
			var numTimelines	: uint	= _timelines.length;
			
			for (var timelineId : uint = 0; timelineId < numTimelines; ++timelineId)
				_timelines[timelineId] = (_timelines[timelineId] as ITimeline).clone();
		}
		
		public function getTimeline(index : uint = 0) : ITimeline
		{
			return _timelines[index];
		}
		
		public function seek(time : Object) : IAnimationController
		{
			var timeValue : uint = getAnimationTime(time);
			
			if (timeValue < _loopBeginTime || timeValue > _loopEndTime)
				throw new Error(
					'Time value is outside of playback window. '
					+'To reset playback window, call resetPlaybackWindow.'
				);
			
			_currentTime = timeValue;
			
			return this;
		}
		
{'fraction_non_alphanumeric': 0.09201303188863659, 'fraction_numerical': 0.0015796228650409715, 'mean_word_length': 3.412020905923345, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5217222', 'n_tokens_mistral': 3880, 'n_tokens_neox': 3109, 'n_words': 759}