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

You are not logged in.

  • Login
  • Register

[Flash AS] fade prototypen

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

1

Friday, July 2nd 2004, 7:13pm

fade prototypen

Hier nen paar prototypen zum skalierung faden alpha und position faden

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
MovieClip.prototype.fade_position = function(xposyposfaktor) {
    this.onEnterFrame = function() {
        this._x += (xpos-this._x)/faktor;
        this._y += (ypos-this._y)/faktor;
        trace(this._x);
        if (Math.round(xpos-this._x) == && Math.round(ypos-this._y) == 0) {
            this._x xpos;
            this._y ypos;
            delete this.onEnterFrame;
        }
    };
}; 




MovieClip.prototype.fade_scale = function (xscal,yscal,faktor) {
    this.onEnterFrame = function () {
        this._xscale += (xscal-this._xscale)/faktor
        this._yscale += (yscal-this._yscale)/faktor
        if (Math.round(xscal-this._xscale) == && Math.round(yscal-this._yscale) == 0) {
            this._xscale xscal
            this._yscale yscal
            delete this.onEnterFrame;
        }
    }
}





MovieClip.prototype.fade_alpha = function (wert,faktor) {
    this.onEnterFrame = function () {
        this._alpha += (wert-this._alpha)/faktor
        if (Math.round(wert-this._alpha) == 0) {
            this._alpha wert
            delete this.onEnterFrame;
        }
    }
}


wie man es aufruft ist klar oder? wenn nicht melden...

viel spaß im anhang als as files

cu mfg
Tschdaeff
Tschdaeff has attached the following file:
  • fade_position.zip (801 Byte - 404 times downloaded - Last download: May 25th 2010, 12:52am)
  • Go to the top of the page

modul47

Beginner

Posts: 5

Location: München

2

Thursday, July 29th 2004, 3:54pm

Moin Tschdaeff

genau das was ich befürchtet hab, bekomm ich nicht hin.

ich hab die functionen aufs erste frame meines filmchens gesetzt und hab nur versucht ein generiertes mc zu skalieren, sobald ein button gedrückt wird.
wie ruf ich das script nun auf, bzw. was muß ich dem button an script geben, damit auf click das sagen wir auf 400% skaliert wird?

danggschön,

modul47
  • Go to the top of the page

fxi

Professional

Posts: 783

Location: Dachau

3

Thursday, July 29th 2004, 4:17pm

ActionScript-Quelltext

1
2
3
_root.mein_btn.onRelease=function(){
    _root.mein_mc.fade_scale(400,400,2)
}
gr33tz fxi


Dem Signatör ist nix zu schwör
  • Go to the top of the page

modul47

Beginner

Posts: 5

Location: München

4

Thursday, July 29th 2004, 5:22pm

danke für die schnell antwort.

prinzipiell funktionierts, aber der mc den ich skalieren will bewegt sich dabei gleich noch nach unten aus dem swf heraus und skaliert nicht auf der stelle.
da ich den mc ja dynamisch generiert haben, kann ich auch den nullpunkt nicht verschieben oder ähnliches...

so sieht das bei mir im moment aus:

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
MovieClip.prototype.base = function(name2xywhebene) { 
    this.createEmptyMovieClip(name2ebene); 
    with (this[name2]) { 
        beginFill(0066330); 
        lineStyle(0111111100); 
        moveTo(xy); 
        lineTo(x+wy); 
        lineTo(x+wy+h); 
        lineTo(xy+h); 
        lineTo(xy); 
        endFill(); 
    } 
}; 
this.base("menu_leiste"500605701); 
this.base("navi_leiste"015010302); 
this.base("ct_frame"2002005003503); 

MovieClip.prototype.fade_scale = function (xscal,yscal,faktor) {
    this.onEnterFrame = function () {
        this._xscale += (xscal-this._xscale)/faktor
        this._yscale += (yscal-this._yscale)/faktor
        if (Math.round(xscal-this._xscale) == 0) {
            this._xscale xscal
            this._yscale yscal
            delete this.onEnterFrame;
        }
    }
}

_root.bt1.onRelease=function(){
    _root.navi_leiste.fade_scale(400,400,8)
}


danke,

modul
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

5

Thursday, July 29th 2004, 5:33pm

klar kannste den nullpunkt verschieben du musst mit lineto nicht bei 0,0 anfangen du kannst auch

ActionScript-Quelltext

1
lineTo (-halbebreite,-halbehoehe)


sowas in die richtung... ansonsten ist klar das er es nicht auf der stelle macht ;)

cu mfg
Tschdaeff
  • Go to the top of the page

modul47

Beginner

Posts: 5

Location: München

6

Thursday, July 29th 2004, 5:53pm

aber warum bleibt das ding nicht an der gleichen stelle?
selbst wenn ich den nullpunkt mittig setzte, oder auf 0/0 sollte das skalieren doch um diesen punkt gehen...

beim skalieren mit dem obigen script schiebts das mc aber irgendwo aufn y-wert ausserhalb meines swfs

kapier nüschts... *kopfkratz*
  • Go to the top of the page

kelor

Super Moderator

Posts: 3,408

Location: formel1-stadt hockenheim

7

Thursday, July 29th 2004, 7:13pm

der swf, der erstellt wurde, den du skalieren willst, dermuss auf

x-koord : 0 - halbe breite

und

y-koord : 0 - halbe höhe erstellt werden


also z.bsp.

erstellen und mit inhalt füllen, dann um die werte verschieben...also anstatt - angenommen er wäre 100 breit und 100 hoch:

_x = 200 muss der auf _x = -50 und -y = - 50

dann kann man den auch korrekt skalieren...


ActionScript-Quelltext

1
2
3
4
5
6
7
8
9
10
11
12
//vorm skalieren
this._width;
this._heigth;


//nach dem skalieren
f=  (this._xscale)/100  // z.bsp. 400% dividiert durch 100 = 4
nx - (f/2);
ny - (f/2);

this._x nx;
this._y ny;


so in der art sollte das funktionieren...


greetz

kelor
[ActionScript-Trainer] [Referent ActionScript] [Buchautor]
[Online/Offline Flash_Applications & Developer]
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

8

Friday, July 30th 2004, 12:21am

da muss aber noch die breite bzw die höhe des mcs rein kelor... oder net?

überleg das beispiel mal mit breite und höhe 2 und dann mal mit breite und
höhe 400...

dann stimmt die verschiebung nicht mehr... das prob hatte ich erst neulich..

deine zoomklasse kann sowas ja

cu mfg
Tschdaeff
  • Go to the top of the page

modul47

Beginner

Posts: 5

Location: München

9

Friday, July 30th 2004, 3:41pm

hm... irgendwie check ich das nicht...
ich weiß a.) nicht, an welche stellen die scripts rein müssen (hab verschiedenes ausprobiert)
und b.) kapier ich das prinzip noch nicht so ganz...

ich stell ein viereck her, mit dem prototype-script, dabei setz ich den nullpunkt (?? - lineTo (-halbebreite,-halbehoehe) - ??) aber wohin im script?

und dann skalier ich und er skaliert dann richtig?

puha *kopfkratz*
  • Go to the top of the page

kelor

Super Moderator

Posts: 3,408

Location: formel1-stadt hockenheim

10

Friday, July 30th 2004, 3:44pm

@tschdaeff: jaja...sollte auch nur n gedankenanstoss sein...
und ja...meine zoom-klasse hat das bereits drin...

greetz

kelor
[ActionScript-Trainer] [Referent ActionScript] [Buchautor]
[Online/Offline Flash_Applications & Developer]
  • Go to the top of the page

modul47

Beginner

Posts: 5

Location: München

11

Friday, July 30th 2004, 4:35pm

deine zoom-klasse hab ich mir grad angeguckt. jetzt versteh ich gar nix mehr. :)
na egal, ich hab jetzt mit undynamischen mcs mal rumprobiert und da funktioniert das dann ja prima, da ich den nullpunkt einfach festlegen kann.

dazu jetzt ne andere frage: muß ich mit prozenten arbeiten? fixe pixelwerte wären doch viel komfortabler eigentlich, oder?
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

12

Tuesday, August 10th 2004, 6:54pm

wenn du mit width und height arbeitest dann hast du doch werte und net
prozent ;)

cu mfg
Tschdaeff
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

13

Wednesday, June 15th 2005, 12:25pm

hi. Fxi hat mich gerade auf etwas aufmerksam gemacht... das teil hatten nen
fehler wenn man ygefadet hat dann war das nicht so wie es hätte sein sollen

von hier aus nochmal danke!

die scripts habe ich ganz oben verbessert

cu mfg
Tschdaeff
  • Go to the top of the page

Vmax

Intermediate

Posts: 172

Location: Heilbronn

14

Saturday, October 7th 2006, 3:29pm

So ich hab das Script von Tschdaeff von fxi auch empfohlen bekommen. Nach den üblichen Anfängerfehlern hab ich es zum Laufen bekommen. Nur wenn ich zwei Funktionen auf einmal aufrufen möchte, klappt das nicht. Es geht nur das fade_alpha ?(

Hier meine AS:


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
MovieClip.prototype.fade_position = function (xpos,ypos,faktor) {
this.onEnterFrame = function () {
this._x += (xpos-this._x)/faktor
this._y += (ypos-this._y)/faktor
if (Math.round(xpos-this._x) == 0) {
this._x xpos
this._y ypos
delete this.onEnterFrame;
}
}
}
MovieClip.prototype.fade_alpha = function (wert,faktor) {
this.onEnterFrame = function () {
this._alpha += (wert-this._alpha)/faktor
if (Math.round(wert-this._alpha) == 0) {
this._alpha wert
delete this.onEnterFrame;
}
}
}

content_mc.onRelease = function(){
display_mc.fade_position(600,0,6)
}
content_mc.onRelease = function(){
display_mc.fade_alpha(100,6)
}
Greetings Vmax
____________________________________________________

Windows 95 was unable to detect your keyboard.
Press F1 to retry or F2 to abort!

This post has been edited 1 times, last edit by "Vmax" (Oct 7th 2006, 3:29pm)

  • Go to the top of the page

fxi

Professional

Posts: 783

Location: Dachau

15

Saturday, October 7th 2006, 5:16pm

so gehts

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
MovieClip.prototype.fade_position = function(xposyposfaktorobj) {
    this.createEmptyMovieClip('move_object'1234);
    var mc this['move_object'];
    mc.onEnterFrame = function() {
        obj._x += (xpos-obj._x)/faktor;
        obj._y += (ypos-obj._y)/faktor;
        if (Math.round(xpos-obj._x) == 0) {
            obj._x xpos;
            obj._y ypos;
            delete mc.onEnterFrame;
        }
    };
};
MovieClip.prototype.fade_alpha = function(wertfaktorobj) {
    this.createEmptyMovieClip('alpha_object'12345);
    var mc this['alpha_object'];
    mc.onEnterFrame = function() {
        obj._alpha += (wert-obj._alpha)/faktor;
        if (Math.round(wert-obj._alpha) == 0) {
            obj._alpha wert;
            delete mc.onEnterFrame;
        }
    };
};
content_mc.onRelease = function() {
    fade_position(60006display_mc);
    fade_alpha(1006display_mc);
};
gr33tz fxi


Dem Signatör ist nix zu schwör
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

16

Saturday, October 7th 2006, 7:03pm

ok ist ne lösung wobei ich das dann so machen würde, dass man die mcs vllt in nem extra onEnterFrame container mc machen würde. oder man übergibt noch ne zeitleiste und macht dann die 2 mcs die da temporär erstellt werden per

zeitleiste.getNextHighestDepth();


also nicht das man die 2 ebenen fest angibt wie es oben gemacht wurde das würde ich vermeiden...


cu mfg
Tschdaeff
  • Go to the top of the page

Vmax

Intermediate

Posts: 172

Location: Heilbronn

17

Monday, October 9th 2006, 3:47pm

Quoted

also nicht das man die 2 ebenen fest angibt wie es oben gemacht wurde das würde ich vermeiden...


@ Taschdaeff: warum?

@fxi: ich bekomme nun folgende Fehlermeldung:

Quoted

**Fehler** C:\Dokumente und Einstellungen\Peter\Desktop\fade position\fade_position.as: Zeile 11: Klassenskripts in ActionScript 2.0 können nur Klassen- oder Schnittstellenkonstrukte definieren.


Kann aber nicht genau erkennen, was da in AS 2.0 anders ist ?(
Greetings Vmax
____________________________________________________

Windows 95 was unable to detect your keyboard.
Press F1 to retry or F2 to abort!
  • Go to the top of the page

fxi

Professional

Posts: 783

Location: Dachau

18

Monday, October 9th 2006, 4:43pm

warum :

Quoted

fade_position.as
?
gr33tz fxi


Dem Signatör ist nix zu schwör
  • Go to the top of the page

Vmax

Intermediate

Posts: 172

Location: Heilbronn

19

Monday, October 9th 2006, 5:04pm

Quoted

Original von fxi
warum :

Quoted

fade_position.as
?


was willste wissen, warum das fade_position heißt?
Greetings Vmax
____________________________________________________

Windows 95 was unable to detect your keyboard.
Press F1 to retry or F2 to abort!
  • Go to the top of the page

Tschdaeff

Super Moderator

Posts: 4,062

Location: Ba-Wü

20

Monday, October 9th 2006, 5:55pm

zum beispiel wenn jemand mit 2 dim arrays arbeitet und die ebenen aus x und y koordinate dann kann es sein das du 2 mal die gleiche ebene verwendest und dann überscheibst du einen clip...


cu mfg
Tschdaeff
  • Go to the top of the page