///////////////////////////////////////////////////////////////////////////////// // Copyright © 2008-2010 W. Kowarschick // // Dieses Werk darf unter den Bedingungen der Creative Common Lizenz by-nc 3.0 de // (http://creativecommons.org/licenses/by-nc/3.0/de/) // vervielfaeltigt, verbreitet, publiziert und modifiziert werden. ///////////////////////////////////////////////////////////////////////////////// package die.view { import flash.display.MovieClip; /** * This MovieClip displays a pip (of a dice; German: Würfelauge). *
A pip has two values: "on" (visible) and "off" (not visible).
* * @author Wolfgang Kowarschick * @category Class * @langversion 3.0 */ public class Pip extends MovieClip { ///////////////////////////////////////////////////////////////////////////// // Constants ///////////////////////////////////////////////////////////////////////////// public static const OFF: int = 0; public static const ON: int = 1; ///////////////////////////////////////////////////////////////////////////// // Instance Variables ///////////////////////////////////////////////////////////////////////////// private var v_value: int; ///////////////////////////////////////////////////////////////////////////// // (Public) Attributes ///////////////////////////////////////////////////////////////////////////// /** The value of the pip: ON or OFF. */ public function get value(): int { return v_value; } public function set value(p_value: int): void { // Integrity check! if (p_value != OFF && p_value != ON) throw (new Error ("Wrong pip value: " + p_value)); v_value = p_value; this.visible = (v_value == ON); /* if (v_value == ON) this.alpha = 1; else this.alpha = 0.1; */ } ///////////////////////////////////////////////////////////////////////////// // Constructor ///////////////////////////////////////////////////////////////////////////// /** * Creates a new pip. * * @param p_value The initial value of the pip: OFF or ON. */ public function Pip(p_value: int = ON) { super(); value = p_value; // p_value is stored AND displayed!!! } ///////////////////////////////////////////////////////////////////////////// // Tracing ///////////////////////////////////////////////////////////////////////////// /** * Converts a Pip object into a string. * * @return Returns the class, the object name and the value * (on or off) of the current pip.
*/
override public function toString(): String
{
return "Pip '" + name + "': " + ((value == ON) ? "ON" : "OFF");
}
/////////////////////////////////////////////////////////////////////////////
// End of class
/////////////////////////////////////////////////////////////////////////////
}
}
/////////////////////////////////////////////////////////////////////////////////
// End of file
/////////////////////////////////////////////////////////////////////////////////