Thursday, July 29th 2010, 1:22pm UTC+2

You are not logged in.

  • Login
  • Register

[ActionScript 2.0] [STUFF] ToolTip

public

Moderator

Posts: 546

Location: Dessau

1

Monday, January 29th 2007, 7:54pm

[STUFF] ToolTip

vllt kanns jemand gebrauchen hab mich ma rangesetzt und ne kliene tooltip klasse geschrieben

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

class:

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:Objecttimeline:MovieClipdepth:Numberstr:String):Void {
        obj.onRollOver Delegate.create (this, function ():Void {
            this.create (timelinedepthstr);
        });
        obj.onRollOut obj.onDragOut Delegate.create (this, function ():Void {
            this.destroy ();
        });
    }
    /*
    *    create (timeline:MovieClip, depth:Number, str:String):Void
    */
    public function create (timeline:MovieClipdepth:Numberstr:String):Void {
        this._id this.setTimeOut (Delegate.create (this, function ():Void {
            this.drawTip (timelinedepthstr);
            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:MovieClipdepth:Numberstr: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"depth001010);
        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 () {
            clearInterval (id);
            func.apply (nullargs);
        }
        var id:Number setInterval (ftime);
        return id;
    }
    /*
    *    clearTimeOut (id:Number):Void 
    */
    private function clearTimeOut (id:Number):Void {
        clearInterval (id);
    }
}


timeline

ActionScript-Quelltext

1
2
3
4
import djpublic.utils.ToolTip;
var t:ToolTip = new ToolTip ();
t.shortcut (test_mcthis1"Hu hu...!\nIk bins.");
t.shortcut (test2_mcthis1"Und nun noch ein HALLO von mir.");
Gänsefleisch ma ihr´n Hund online!?

Inder nett...

This post has been edited 2 times, last edit by "public" (Jan 29th 2007, 8:06pm)

  • Go to the top of the page

lunde1369

Trainee

Posts: 104

Location: Autonome Republik Vogtland

2

Monday, January 29th 2007, 11:04pm

:D :D :D

@public, schläfst du auch irgendwann mal? ach nee, ich vergaß :D :D :D

hoffe, is alles senkrecht in Dessau und Public Mini kerngesund! ;) ;)

lunne
  • Go to the top of the page

public

Moderator

Posts: 546

Location: Dessau

3

Tuesday, January 30th 2007, 12:05am

jo uns gehts soweit ganz gut....ach ja schlafen ? watt n das? *g*
Gänsefleisch ma ihr´n Hund online!?

Inder nett...
  • Go to the top of the page

p-flash

Intermediate

Posts: 368

Location: Düsseldorf

4

Monday, March 12th 2007, 7:45pm

Jo, cooles Teil. Gibt es irgendwelche Einschränkungen bzgl. der Weiterverwendung? :D
--------------------------------
www.p-creations.com

:.Interaktiver Spielplan.:
  • Go to the top of the page

public

Moderator

Posts: 546

Location: Dessau

5

Monday, March 12th 2007, 7:58pm

wie meinstn das genau???
Gänsefleisch ma ihr´n Hund online!?

Inder nett...
  • Go to the top of the page

p-flash

Intermediate

Posts: 368

Location: Düsseldorf

6

Monday, March 12th 2007, 8:06pm

Habe ein paar änderungen gemacht und wollte es für projekte benutzen
--------------------------------
www.p-creations.com

:.Interaktiver Spielplan.:
  • Go to the top of the page

public

Moderator

Posts: 546

Location: Dessau

7

Tuesday, March 13th 2007, 12:55am

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
Gänsefleisch ma ihr´n Hund online!?

Inder nett...
  • Go to the top of the page

Sven G.

Administrator

Posts: 3,343

Location: NRW / Bochum

8

Tuesday, March 13th 2007, 9:13am

Nicht schlecht nicht schlecht :)

Hab es mal in die Scriptcollection verschoben :-)
Mit freundlichen Grüßen
Sven Gasser @ BountyKiller.de
Flashbattle.deGründer
webmaster@flashbattle.de
Flashbattle.de ActionScript Referenz
DELTA Agentur - Agentur für Werbung & Kommunikation
News aus der Medienwelt & mehr @ Delta Agentur twittert

(Kein Support per eMail, PN oder ICQ)

Irren ist menschlich, aber für das totale Chaos braucht man einen Computer :)
http://twitter.com/deltaagentur
  • Go to the top of the page

p-flash

Intermediate

Posts: 368

Location: Düsseldorf

9

Tuesday, March 13th 2007, 9:35am

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


Jo danke.

Die Änderungen sind mit //*#pn markiert.

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 Objectmsg Stringtimeline MovieClipdepth Number):Void
    {
        var tt:ToolTip this;
        
        obj.onRollOver = function():Void 
        {
            if (tt.isActivated()) //*#pn
                tt.create(msgtimelinedepth);
        };
        obj.onRollOut obj.onDragOut = function ():Void
        {
            tt.destroy();
        };
        
        //Mouse.addListener(obj);
    }
    /*
     *    create (timeline:MovieClip, depth:Number, str:String):Void
     */
    public function create(msg Stringtimeline MovieClipdepth Number) : Void
    {//*#pn
        if (timeline == null)     timeline DEFAULT_TIMELINE;
        if (depth == null)        depth     DEFAULT_DEPTH;
        
        this._id setInterval(this"show"this.timemsgtimelinedepth); //*#pn
    }
    private function show (msg Stringtimeline MovieClipdepth Number) : Void
    {
        this.drawTip(msgtimelinedepth);
        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 Stringtimeline MovieClipdepth 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"depth001010);
        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);
    }

}


Ich persönlich arbeite ungern mit Delegate habe deshalb diese Stellen umgeschrieben.

Änderungen:
- timeline und depth sind jetzt optionale parameter. Wenn sie nicht angeben werden, werden die DEFAULT Vars der Klasse genommen. Die Parameter Reihenfolge ist bei den Methoden jetzt anders.
- Das ToolTip kann mit deactive() und activate() ab- bzw angeschaltet werden.
- im onMouseMove() ist ein updateAfterEvent(), dadurch wird die Bewegung "flüssiger"
- Die Zuweisung von __tf geschieht in 2 statt in 1 Schritt. So ist das Tool auch Flash 7 kompatibel. Also:

Quoted


this._mc.createTextField("__ToolTipTextField", depth, 0, 0, 10, 10);
this._tf = this._mc["__ToolTipTextField"];


Habe es bei diesem Projekt angewendet. Das Ein-/Ausschalten des ToolTip ist jetzt auch ganz einfach.

p-flash
--------------------------------
www.p-creations.com

:.Interaktiver Spielplan.:

This post has been edited 2 times, last edit by "p-flash" (Mar 13th 2007, 9:57am)

  • Go to the top of the page