Thursday, July 29th 2010, 1:34pm UTC+2
You are not logged in.
tring [read, write] = "Verdana"
bject, timeline:MovieClip, depth:Number, str
tring):Void
tring):Void|
|
ActionScript-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
import mx.utils.Delegate;
class djpublic.utils.ToolTip {
/*
* PROPERTIES
* bgColor:Number [read, write] = 0xffffcc
* borderColor:Number [read, write] = 0x000000
* textColor:Number [read, write] = 0x000000
* font:String [read, write] = "Verdana"
* fontSize:Number [read, write] = 10
* embededFont:Boolean [read, write] = false
* time:Number [read, write] = 500
*
* METHODES
* shortcut (obj:Object, timeline:MovieClip, depth:Number, str:String):Void
* create (timeline:MovieClip, depth:Number, str:String):Void
* destroy ():Void
*
*
*/
private var _mc:MovieClip;
private var _tf:TextField;
private var _format:TextFormat;
private var _id:Number;
//
private var _bgColor:Number = 0xffffcc;
private var _borderColor:Number = 0x000000;
private var _textColor:Number = 0x000000;
private var _font:String = "Verdana";
private var _fontSize:Number = 10;
private var _time:Number = 500;
private var _embededFont:Boolean = false;
/*
* PROPERTIES
*/
// bgColor
public function set bgColor (value:Number):Void {
this._bgColor = value;
}
public function get bgColor ():Number {
return this._bgColor;
}
// textColor
public function set textColor (value:Number):Void {
this._textColor = value;
}
public function get textColor ():Number {
return this._textColor;
}
// font
public function set font (value:String):Void {
this._font = value;
}
public function get font ():String {
return this._font;
}
// fontSize
public function set fontSize (value:Number):Void {
this._fontSize = value;
}
public function get fontSize ():Number {
return this._fontSize;
}
// borderColor
public function set borderColor (value:Number):Void {
this._borderColor = value;
}
public function get borderColor ():Number {
return this._borderColor;
}
// time
public function set time (value:Number):Void {
this._time = value;
}
public function get time ():Number {
return this._time;
}
// embededFont
public function set embededFont (value:Boolean):Void {
this._embededFont = value;
}
public function get embededFont ():Boolean {
return this._embededFont;
}
function ToolTip () {
}
/*
* shortcut (obj:Object, timeline:MovieClip, depth:Number, str:String):Void
*/
public function shortcut (obj:Object, timeline:MovieClip, depth:Number, str:String):Void {
obj.onRollOver = Delegate.create (this, function ():Void {
this.create (timeline, depth, str);
});
obj.onRollOut = obj.onDragOut = Delegate.create (this, function ():Void {
this.destroy ();
});
}
/*
* create (timeline:MovieClip, depth:Number, str:String):Void
*/
public function create (timeline:MovieClip, depth:Number, str:String):Void {
this._id = this.setTimeOut (Delegate.create (this, function ():Void {
this.drawTip (timeline, depth, str);
this._mc.onEnterFrame = function ():Void {
this._x = timeline._xmouse;
this._y = timeline._ymouse - this._height;
};
}), this.time);
}
/*
* create (timeline:MovieClip, depth:Number, str:String):Void
*/
private function drawTip (timeline:MovieClip, depth:Number, str:String):Void {
this._format = new TextFormat ();
this._format.font = this.font;
this._format.size = this.fontSize;
this._mc = timeline.createEmptyMovieClip ("__ToolTipMovieClip", depth);
this._tf = this._mc.createTextField ("__ToolTipTextField", depth, 0, 0, 10, 10);
this._tf.autoSize = true;
this._tf.border = true;
this._tf.borderColor = this.borderColor;
this._tf.background = true;
this._tf.backgroundColor = this.bgColor;
this._tf.selectable = false;
this._tf.embedFonts = this.embededFont;
this._tf.text = str;
this._tf.setTextFormat (this._format);
//
this._mc._x = timeline._xmouse;
this._mc._y = timeline._ymouse - this._mc._height;
}
/*
* destroy():Void
*/
public function destroy ():Void {
this.clearTimeOut (this._id);
this._mc.removeMovieClip ();
this._tf.removeTextField ();
delete this._mc.onEnterFrame;
}
/*
* setTimeOut (func:Function, time:Number):Void
*/
private function setTimeOut (func:Function, time:Number):Number {
var args:Array = arguments.splice (2);
function f () {
clearInterval (id);
func.apply (null, args);
}
var id:Number = setInterval (f, time);
return id;
}
/*
* clearTimeOut (id:Number):Void
*/
private function clearTimeOut (id:Number):Void {
clearInterval (id);
}
}
|
|
|
ActionScript-Quelltext |
1 2 3 4 |
import djpublic.utils.ToolTip;
var t:ToolTip = new ToolTip ();
t.shortcut (test_mc, this, 1, "Hu hu...!\nIk bins.");
t.shortcut (test2_mc, this, 1, "Und nun noch ein HALLO von mir.");
|
This post has been edited 2 times, last edit by "public" (Jan 29th 2007, 8:06pm)


Quoted
Original von public
klar kannste machen.....wäre aber cool wenn du deine änderungen posten würdest und vllt noch ne kleine beschreibeung was du geändert hast
|
|
ActionScript-Quelltext |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
class djpublic.utils.ToolTip
{
private static var DEFAULT_DEPTH : Number = 12432; //*#pn Wert willkürlich gewählt. Sollte aber hoch sein.
private static var DEFAULT_TIMELINE : MovieClip = _root;
private var activated : Boolean = true;
/*
* PROPERTIES
* bgColor:Number [read, write] = 0xffffcc
* borderColor:Number [read, write] = 0x000000
* textColor:Number [read, write] = 0x000000
* font:String [read, write] = "Verdana"
* fontSize:Number [read, write] = 10
* embededFont:Boolean [read, write] = false
* time:Number [read, write] = 500
*
* METHODES
* shortcut (obj:Object, timeline:MovieClip, depth:Number, str:String):Void
* create (timeline:MovieClip, depth:Number, str:String):Void
* destroy ():Void
*
*
*/
private var _mc : MovieClip;
private var _tf : TextField;
private var _format : TextFormat;
private var _id : Number;
//
private var _bgColor : Number = 0xBFE3EE;
private var _borderColor : Number = 0x003366;
private var _textColor : Number = 0x000000;
private var _font : String = "Verdana";
private var _fontSize : Number = 10;
private var _time : Number = 500;
private var _embededFont : Boolean = false;
/*
* PROPERTIES
*/
// bgColor
public function set bgColor(value : Number) : Void
{
this._bgColor = value;
}
public function get bgColor() : Number
{
return this._bgColor;
}
// textColor
public function set textColor(value : Number) : Void
{
this._textColor = value;
}
public function get textColor() : Number
{
return this._textColor;
}
// font
public function set font(value : String) : Void
{
this._font = value;
}
public function get font() : String
{
return this._font;
}
// fontSize
public function set fontSize(value : Number) : Void
{
this._fontSize = value;
}
public function get fontSize() : Number
{
return this._fontSize;
}
// borderColor
public function set borderColor(value : Number) : Void
{
this._borderColor = value;
}
public function get borderColor() : Number
{
return this._borderColor;
}
// time
public function set time(value : Number) : Void
{
this._time = value;
}
public function get time() : Number
{
return this._time;
}
// embededFont
public function set embededFont(value : Boolean) : Void
{
this._embededFont = value;
}
public function get embededFont() : Boolean
{
return this._embededFont;
}
function ToolTip()
{
}
/*
* shortcut (obj:Object, timeline:MovieClip, depth:Number, str:String):Void
*/
public function shortcut(obj : Object, msg : String, timeline : MovieClip, depth : Number):Void
{
var tt:ToolTip = this;
obj.onRollOver = function():Void
{
if (tt.isActivated()) //*#pn
tt.create(msg, timeline, depth);
};
obj.onRollOut = obj.onDragOut = function ():Void
{
tt.destroy();
};
//Mouse.addListener(obj);
}
/*
* create (timeline:MovieClip, depth:Number, str:String):Void
*/
public function create(msg : String, timeline : MovieClip, depth : Number) : Void
{//*#pn
if (timeline == null) timeline = DEFAULT_TIMELINE;
if (depth == null) depth = DEFAULT_DEPTH;
this._id = setInterval(this, "show", this.time, msg, timeline, depth); //*#pn
}
private function show (msg : String, timeline : MovieClip, depth : Number) : Void
{
this.drawTip(msg, timeline, depth);
this._mc.onMouseMove = function():Void
{
this._x = timeline._xmouse + 5;
this._y = timeline._ymouse + 25; //- this._height;
updateAfterEvent(); //*#pn "flüssigere" Bewegung
};
clearTimeOut(this._id);
}
/*
* create (timeline:MovieClip, depth:Number, str:String):Void
*/
private function drawTip(msg : String, timeline : MovieClip, depth : Number) : Void
{
/* Falls diese Methode nicht nur von create() aufgerufen wird, if-Anweisungen nicht auskommentieren!
if (timeline == null) timeline = DEFAULT_TIMELINE;
if (depth == null) depth = DEFAULT_DEPTH;
*/
this._format = new TextFormat();
this._format.font = this.font;
this._format.size = this.fontSize;
this._mc = timeline.createEmptyMovieClip("__ToolTipMovieClip", depth);
this._mc.createTextField("__ToolTipTextField", depth, 0, 0, 10, 10);
this._tf = this._mc["__ToolTipTextField"]; //*#pn
this._tf.autoSize = true;
this._tf.border = true;
this._tf.borderColor = this.borderColor;
this._tf.background = true;
this._tf.backgroundColor = this.bgColor;
this._tf.selectable = false;
this._tf.embedFonts = this.embededFont;
this._tf.text = msg;
this._tf.setTextFormat(this._format);
//
this._mc._x = timeline._xmouse;
this._mc._y = timeline._ymouse + 25; //- this._height;
}
/*
* destroy():Void
*/
public function destroy() : Void
{
this.clearTimeOut (this._id);
this._mc.removeMovieClip();
this._tf.removeTextField();
delete this._mc.onMouseMove;
}
//*#pn
public function isActivated () : Boolean
{
return activated;
}
//*#pn
public function activate () : Void
{
activated = true;
}
//*#pn
public function deactivate () : Void
{
activated = false;
}
/*
* setTimeOut (func:Function, time:Number):Void
*/
/*private function setTimeOut (func:Function, time:Number):Number {
var args:Array = arguments.splice (2);
function f () {
clearInterval (id);
func.apply (null, args);
}
var id:Number = setInterval (f, time);
return id;
}*/
/*
* clearTimeOut (id:Number):Void
*/
private function clearTimeOut (id : Number) : Void
{
clearInterval(id);
}
}
|
Quoted
this._mc.createTextField("__ToolTipTextField", depth, 0, 0, 10, 10);
this._tf = this._mc["__ToolTipTextField"];
This post has been edited 2 times, last edit by "p-flash" (Mar 13th 2007, 9:57am)