Показать сообщение отдельно
Старый 28.01.2006, 22:06
Antares вне форума Посмотреть профиль Найти все сообщения от Antares
  № 2  
Antares
Banned
 
Аватар для Antares

Регистрация: Dec 2003
Сообщений: 3,925
Берем два класса и проблема решена.
Код:
///////////////////////////////////////////////////////////
//  VisualObject.as
//  Original author: Michael Klishin
///////////////////////////////////////////////////////////

import mx.events.EventDispatcher;

import mx.transitions.Tween;
import mx.transitions.easing.Regular;

/**
 * @date        26.07.2004
 * @author Michael Klishin
 * @version 1.0
 */
class com.novemberain.display.VisualObject extends MovieClip
{
	// ---------------------------------------> Private props
	
	// ---------------------------------------> Public props
	
	/**
	 * For EventDispatcher
	 */
	public var addEventListener : Function;
	/**
	 * For EventDispatcher
	 */
	public var dispatchEvent : Function;

	/**
	 * For EventDispatcher
	 */
	public var removeEventListener : Function;
	
	/**
	 * For EventDispatcher
	 */
	public var dispatchQueue : Function;

	// ---------------------------------------> Constructor

	public function VisualObject ( ) 
	{
		// Initialize object with EventDispatcher
		EventDispatcher.initialize( this );
	}
	
	/**
	 * Initializes object
	 * 
	 * Override in subclasses
	 */
	public function init( ) : Void
	{
		// TODO : Override
	}
	
   
    /**
     * Hides object
     */
    public function hide(): Void
    {
	    this._visible = false;
    }

    /**
     * Moves object into specified coordinates
     * 
     * @param x		x coordinate
     * @param y		y coordinate
     * 
     * @return		Nothing
     */
    public function move( x:Number, y:Number ): Void
    {
	    this._x = x;
	    this._y = y;
    }

    /**
	 * Shows object
     */
    public function show(): Void
    {
	    this._visible = true;
    }

    /**
     * Moves object into specified position with Tween class
     * 
     * @param x				x coordinate
     * @param y				y coordinate
     * @param relative		Are coordinates relative to the current object's coords?
     * @param time			Time of movement
     * @param type			Tween movement type
     * @param callback		Function to execute when motion stops. Pass null to omit this.
     * 
     * @return				Nothing
     */
    public function slideTo(x:Number, y:Number, relative:Boolean, time:Number, type:Object, callback:Function): Void
    {
		// По умолчанию тип Elastic.easeOut
		if( type == undefined || type == null ) 
			type = Regular.easeOut;
		
		// Относительно или нет заданы координаты
		if(relative)
		{
			var xTo:Number = this._x + x;
			var yTo:Number = this._y + y;			
		} else
		{
			var xTo:Number = x;
			var yTo:Number = y;
		}
		
		var xTween:Tween = new Tween(this, '_x', type, this._x, xTo, time, true );
		var yTween:Tween = new Tween(this, '_y', type, this._y, yTo, time, true );
		
		// Callback
		if(callback) 
			xTween.onMotionStopped = callback;
		
		// Поехали?
		xTween.start();
		yTween.start();
    }

	/**
	 * getNextHighestDepth for Flash Player 6
	 * 
	 *   
	 * @return  	Number		Next highest depth
	 */
    public function getNextHighestDepth(): Number
    {
	    // Итератор
	    var key:Object = {};
	    
	    var max:Number = 0;
	    for( key in this )
	    {
		    if( (typeof( this[key] ) == "movieclip" || typeof( this[key] ) == "textfield") && this[key]._parent == this && this[key]._name == key )
		    {
			    if( this[key].getDepth() > max )
				max = this[key].getDepth();
		    }
	    }
	    
	    return max + 1;
    } 
	
  
    // -------------------------------------------------------------------------> Getters / Setters
    

}
От него наследуется
Код:
import ascb.util.Proxy;
import com.novemberain.display.VisualObject;


/**
 * @version 1.0
 * @created 14-08-2004 2:33:17
 */
class com.novemberain.display.InteractiveObject extends VisualObject 
{
	
	public function InteractiveObject( )
	{
		super();
	}
	
	
	// -----------------------------
	
	
	public function onRollOver() :  Void
	{
		if( this.enabled )
		{
			dispatchEvent( {type:"onRollOver", target:this} );			
		}	
	}
	
	public function onRollOut() :  Void
	{
		if( this.enabled )
		{
			dispatchEvent( {type:"onRollOut", target:this} );
		}	
	}
	
	public function onPress() :  Void
	{
		if( this.enabled )
		{
			dispatchEvent( {type:"onPress", target:this} );
		}	
	}
	
	public function onRelease() : Void
	{
		if( this.enabled )
		{
			dispatchEvent( {type:"onRelease", target:this} );
		}		
	}
}
Вопросы?