Показать сообщение отдельно
Старый 12.02.2008, 22:21
ALiEN_ вне форума Посмотреть профиль Отправить личное сообщение для ALiEN_ Посетить домашнюю страницу ALiEN_ Найти все сообщения от ALiEN_
  № 3  
Ответить с цитированием
ALiEN_
UFO
 
Аватар для ALiEN_

Регистрация: Jul 2007
Сообщений: 173
Код:
package classes.movers
{
	
	import classes.parsers.Easing;
	
	import fl.transitions.Tween;
	
	import flash.utils.*;
	
	
	public class SmoothMover
	{
	
		private var tweenX, tweenY;
		
		private var duration;
		
		private var typeMotion;
		
		private var object;
		
		
		public function SmoothMover ( object, typeMotion, duration )
		{
			
			object.smoothX = object.x;
			object.smoothY = object.y;
			
			this.object = object;
			this.typeMotion = typeMotion;
			this.duration = duration;
			
			tweenX = new Tween ( object, "x", typeMotion, object.x, object.smoothX, duration, false );
			tweenY = new Tween ( object, "y", typeMotion, object.y, object.smoothY, duration, false );
			
			setInterval ( move, 100 );
			
		}
		
		
		static public function add ( object, t:String, mot:String, duration:Number )
		{
			
			if (object.smoothMover == undefined) 
			{
				
				object.smoothMover = new SmoothMover ( object, Easing.get ( t, mot ), duration );
				
			}
			
		}

							   
		private function move ()
		{
		
			if ( tweenX.isPlaying )
			{
				
				tweenX.continueTo ( object.smoothX, duration );
				tweenY.continueTo ( object.smoothY, duration );
				
			}
			
			else
			{
				
				tweenX = new Tween ( object, "x", typeMotion, object.x, object.smoothX, duration, false );
				tweenY = new Tween ( object, "y", typeMotion, object.y, object.smoothY, duration, false );
				
			}
				
		}
					
    }
	
}