Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 12-06-2005, 10:56   #1 (permalink)
Neuer User
 
Registriert seit: Jun 2005
Beiträge: 43
Drag und Drop: zurück

Hallo,

Ich habe einen Kreis (Movieclip). Diesen Kreis möchte ich bei gedrückter Maustaste verschieben und beim loslassen der Maustaste, soll der Kreis wieder zum Ursprung zurückkehren (wo er vor dem verschieben gewesen ist).
Logisch kann ich mir es vorstellen aber leider nicht praktisch umsetzen

Weiß jemand eine Lösung?

Mein Skript soweit zum verschieben:

ActionScript:
  1. Kreis.onPress = function() {
  2.     startDrag(Kreis);
  3. }
  4.  
  5. Kreis.onRelease = Kreis.onReleaseOutside = function() {
  6.     stopDrag();
  7.    
  8. }
Koushi ist offline   Mit Zitat antworten
Alt 12-06-2005, 12:17   #2 (permalink)
agedoubleju
Gast
 
Beiträge: n/a
ActionScript:
  1. Kreis.onPress = function() {
  2.         startDrag(Kreis);
  3.        _global.posx = this._x;
  4.        _global.posy = this._y;
  5. }
  6.  
  7. Kreis.onRelease = Kreis.onReleaseOutside = function() {
  8.         stopDrag();
  9.         this._x = _global.posx;
  10.         this._y = _global.posy;
  11. }
  Mit Zitat antworten
Alt 12-06-2005, 13:09   #3 (permalink)
Padawan
 
Benutzerbild von Annkai
 
Registriert seit: Jun 2005
Beiträge: 40
Wie bekommt man es hin, dass die Bewegung (Tween) sichtbar wird?
Sowas wie sleep gibt es in AS ja nicht.

ActionScript:
  1. createEmptyMovieClip("Kreis", 1);
  2. with (Kreis) {
  3.     lineStyle(100, 0xff0000, 100);
  4.     moveTo(50, 50);
  5.     lineTo(50, 50.15);
  6. }
  7. Kreis.onPress = function() {
  8.     startDrag(Kreis);
  9.     _global.posx = this._x;
  10.     _global.posy = this._y;
  11. };
  12. Kreis.onRelease = Kreis.onReleaseOutside=function () {
  13.     while (this._x != _global.posx) {
  14.         this._x--;
  15.     }
  16.     while (this._y != _global.posy) {
  17.         this._y--;
  18.     }
  19.     stopDrag();
  20. };
Annkai ist offline   Mit Zitat antworten
Alt 12-06-2005, 13:17   #4 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Hallo!
Das ginge so z.B. ist aber wohl etwas "lahm":
ActionScript:
  1. createEmptyMovieClip("Kreis", 1);
  2. with (Kreis) {
  3.     lineStyle(100, 0xff0000, 100);
  4.     moveTo(50, 50);
  5.     lineTo(50, 50.15);
  6. }
  7. Kreis.onPress = function() {
  8.     _global.x = false;
  9.     _global.y = false;
  10.     startDrag(Kreis);
  11.     _global.posx = this._x;
  12.     _global.posy = this._y;
  13. };
  14. Kreis.onRelease = Kreis.onReleaseOutside=function () {
  15.     stopDrag();
  16.     this.onEnterFrame = function() {
  17.         this._x>_global.posx ? this._x-- : this._x<_global.posx ? this._x++ :_global.x=true;
  18.         this._y>_global.posy ? this._y-- : this._y<_global.posy ? this._y++ :_global.y=true;
  19.         x == true && y == true ? (delete this.onEnterFrame, trace("deleted")) : 0;
  20.     };
  21. };
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 12-06-2005, 14:00   #5 (permalink)
Padawan
 
Benutzerbild von Annkai
 
Registriert seit: Jun 2005
Beiträge: 40
Aha - Danke, wieder was gelernt...
Dass mit dem onEnterFrame muss ich mir noch in den Kopf reinhauen!
Aber dass man keinen Einfluss auf die Geschwindigkeit hat ist nicht sehr vorteilhaft.
Wenn man z.B. this._x-=5 schreibt, erhält man einen unschönen Effekt, vorrausgesetzt man zieht den Kreis nicht um eine Pixelzahl gleich glatt durch 5 teilbar nach links.
Annkai ist offline   Mit Zitat antworten
Alt 12-06-2005, 14:09   #6 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Und wie wäre sowas:
ActionScript:
  1. createEmptyMovieClip("Kreis", 1);
  2. with (Kreis) {
  3.         lineStyle(100, 0xff0000, 100);
  4.         moveTo(50, 50);
  5.         lineTo(50, 50.15);
  6. }
  7. Kreis.onPress = function() {
  8.     delete this.onEnterFrame;
  9.         _global.x = false;
  10.         _global.y = false;
  11.         startDrag(Kreis);
  12.         _global.posx = this._x;
  13.         _global.posy = this._y;
  14. };
  15. Kreis.onRelease = Kreis.onReleaseOutside=function () {
  16.         stopDrag();
  17.         this.onEnterFrame = function() {
  18.                 this._x>posx ? this._x-=(posx+this._x)/5 : this._x<posx ? this._x+=(posx-this._x)/5 :_global.x=true;
  19.                 this._y>posy ? this._y-=(posy+this._y)/5 : this._y<posy ? this._y+=(posy-this._y)/5 :_global.y=true;
  20.                 x == true && y == true ? (delete this.onEnterFrame, trace("deleted")) : 0;
  21.         };
  22. };
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 12-06-2005, 14:14   #7 (permalink)
Padawan
 
Benutzerbild von Annkai
 
Registriert seit: Jun 2005
Beiträge: 40
Mist, warum komme ich auf sowas nicht selbst!
Würde sagen - Genial!

Kannst Du mir noch schnell verraten für was die 0 am Ende steht?

Danke für die schnelle Antwort :-)

Geändert von Annkai (12-06-2005 um 14:15 Uhr)
Annkai ist offline   Mit Zitat antworten
Alt 12-06-2005, 14:18   #8 (permalink)
................
 
Benutzerbild von Der Frager
 
Registriert seit: Jun 2004
Beiträge: 15.890
Einmal noch . Habe festgestellt, dass der onEnterFrame nicht immer gekillt wird. Also doch lieber so:
ActionScript:
  1. createEmptyMovieClip("Kreis", 1);
  2. with (Kreis) {
  3.     lineStyle(100, 0xff0000, 100);
  4.     moveTo(50, 50);
  5.     lineTo(50, 50.15);
  6. }
  7. Kreis.onPress = function() {
  8.     delete this.onEnterFrame;
  9.     startDrag(Kreis);
  10.     _global.posx = this._x;
  11.     _global.posy = this._y;
  12. };
  13. Kreis.onRelease = Kreis.onReleaseOutside=function () {
  14.     stopDrag();
  15.     this.onEnterFrame = function() {
  16.         this._x>posx ? this._x -= (posx+this._x)/5 : this._x<posx ? this._x += (posx-this._x)/5 : 0;
  17.         this._y>posy ? this._y -= (posy+this._y)/5 : this._y<posy ? this._y += (posy-this._y)/5 : 0;
  18.         Math.round(this._y) == Math.round(posy) && Math.round(this._x) == Math.round(posx) ? (delete this.onEnterFrame, trace("deleted")) : 0;
  19.     };
  20. };
__________________

ternärer Konditionaloperator

+++ Bitte keine Privat-Nachrichten bezüglich Flashfragen! +++
Der Frager ist offline   Mit Zitat antworten
Alt 12-06-2005, 14:23   #9 (permalink)
Neuer User
 
Registriert seit: Jun 2005
Beiträge: 43
Wow, vielen Dank auch allen! Und Danke Holger, so kurz und kompakt habe ich es gebraucht.

Vielen Dank!

cu
Koushi
Koushi ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 04:03 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele