Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 21-02-2005, 10:24   #1 (permalink)
duc
c'est possible
 
Registriert seit: Jan 2004
Ort: Schwitzerland
Beiträge: 80
drawLine aber bitte langsam

hallo zusammen ich habe folgende frage:
gibt es eine möglichkeit, das ich via actionscript eine linie zeichnen (lassen) kann, welche sich à la bewegungstween fortbewegt. sprich nicht z.B. per mouseklick auf button von Koorinate A nach B "springt", sondern nur "fliesst"?
alles verstanden?
Merci für eure Feedbacks.
Grüsse duc



_root.lineStyle(1, 0x0000FF, 100);
_root.lineTo(100, 75);
duc ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:08   #2 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Quick and dirty vielleicht so:
ActionScript:
  1. _root.createEmptyMovieClip("line", 1);
  2.  with (_root.line) {
  3.      lineStyle(1, 0xFF0000);
  4.  }
  5.  function drawL(vonx, vony, bisx, bisy) {
  6.      _root.line.moveTo(vonx, vony);
  7.      _root.line.onEnterFrame = function() {
  8.          if (vonx < bisx && vony < bisy) {
  9.              this.lineTo(vonx += 2, vony += 2);
  10.          } else {
  11.              delete this.onEnterFrame;
  12.          }
  13.      };
  14.  }
  15.  drawL(0, 0, 100, 300);
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------

Geändert von thebiz (21-02-2005 um 11:09 Uhr)
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:11   #3 (permalink)
duc
c'est possible
 
Registriert seit: Jan 2004
Ort: Schwitzerland
Beiträge: 80
probiers grad aus...

@thebiz
danke dir, werd es gleich testen.....geb dir bescheid wies ausviel....gruss duc
duc ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:13   #4 (permalink)
duc
c'est possible
 
Registriert seit: Jan 2004
Ort: Schwitzerland
Beiträge: 80
verlangsamern am ende???

@thebiz:
ist prima, danke nochmals. nun, kann mann da auch ne art verlangsamung gegen ende einbauen?

gruss duc
duc ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:15   #5 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Ich bastle gerade dran rum.
Will das Ding mal etwas abwandeln.
Kleinen Moment .
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:25   #6 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Wie wäre es damit?:

ActionScript:
  1. _root.createEmptyMovieClip("line", 1);
  2. with (_root.line) {
  3.     lineStyle(1, 0xFF0000);
  4. }
  5. function drawL(vonx, vony, bisx, bisy) {
  6.     _root.line.moveTo(vonx, vony);
  7.     time = 0;
  8.     _root.line.onEnterFrame = function() {
  9.         if (time < 100) {
  10.             time += 5;
  11.             vonx += (bisx - vonx) / 10;
  12.             vony += (bisy - vony) / 10;
  13.             this.lineTo(vonx, vony);
  14.         } else {
  15.             delete this.onEnterFrame;
  16.             drawL(vonx, vony, Math.round(Math.random() * 300), Math.round(Math.random() * 300));
  17.         }
  18.     };
  19. }
  20. drawL(0, 0, 100, 300);
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:34   #7 (permalink)
duc
c'est possible
 
Registriert seit: Jan 2004
Ort: Schwitzerland
Beiträge: 80
@thebiz

hehe du bist wahnsinnig
nun ich würd sagen, ist ziemlich hiammer hehe.
nein aber es ist doch grad zu abartig, können wir nicht einfach bei einer linie bleiben, die getweent wird?

z.B.: x=50 y=50
dannn der endpunkt: x=500 y=50


ist dies folgendes?

drawL(50, 50, 500, 50); ?????

merci und gruzz duc
duc ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:36   #8 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Bin gerade dabei.
Muss noch eine Fallunterscheidung einbauen.
Mal sehen ob das so überhaupt klappt.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:39   #9 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
So das sollte passen. voilà
ActionScript:
  1. _root.createEmptyMovieClip("line", 1);
  2. with (_root.line) {
  3.     lineStyle(1, 0xFF0000);
  4. }
  5. function drawL(vonx, vony, bisx, bisy) {
  6.     _root.line.moveTo(vonx, vony);
  7.     _root.line.onEnterFrame = function() {
  8.         if (Math.abs(vonx) > Math.abs(bisx - 3) || Math.abs(vonx) > Math.abs(bisx + 3) && Math.abs(vony) > Math.abs(bisy - 3) || Math.abs(vony) > Math.abs(bisx + y)) {
  9.             delete this.onEnterFrame;
  10.         } else {
  11.             vonx += (bisx - vonx) / 5;
  12.             vony += (bisy - vony) / 5;
  13.             this.lineTo(vonx, vony);
  14.         }
  15.     };
  16. }
  17. drawL(0, 0, 100, 300);
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:45   #10 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Etwas schöner verpackt.
ActionScript:
  1. var easingStrength = 10;
  2.  _root.createEmptyMovieClip("line", 1);
  3.  with (_root.line) {
  4.      lineStyle(1, 0xFF0000);
  5.  }
  6.  //------------------------------------------
  7.  function drawL(vonx, vony, bisx, bisy) {
  8.      _root.line.moveTo(vonx, vony);
  9.      _root.line.onEnterFrame = function() {
  10.          if (Math.abs(vonx) > Math.abs(bisx - 3) || Math.abs(vonx) > Math.abs(bisx + 3) && Math.abs(vony) > Math.abs(bisy - 3) || Math.abs(vony) > Math.abs(bisx + y)) {
  11.              delete this.onEnterFrame;
  12.          } else {
  13.              vonx += (bisx - vonx) / easingStrength;
  14.              vony += (bisy - vony) / easingStrength;
  15.              this.lineTo(vonx, vony);
  16.          }
  17.      };
  18.  }
  19.  //------------------------------------------
  20.  drawL(50, 50, 800, 300);
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------

Geändert von thebiz (21-02-2005 um 11:46 Uhr)
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 11:47   #11 (permalink)
duc
c'est possible
 
Registriert seit: Jan 2004
Ort: Schwitzerland
Beiträge: 80
Prima

also ich hab das nun divers getestet und mir den code angeschaut, habe dabei noch verständnisprobleme was die : Math.abs betrifft aber dass sollt ich dann vielleicht schon hinkriegen.
was ich noch bemerkt habe ist, dass die linie gegen ende unscharf wird, bzw. sie wird fast 2 pixel breit. an was könnte dass wohl liegen???

dann noch folgendes(falls du noch zeit und wille hast), wenn ich also jetz ein rechteck zeichnen will, kann ich die 4 punktkoordinaten auch in das drawL(...) einbinden oder wie sähe dass aus?

duc (danke dir tausend)
duc ist offline   Mit Zitat antworten
Alt 21-02-2005, 12:25   #12 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Bin dabei.
Hatte etwas Problem.
Kann noch ein paar Minuten dauern.
Danach ist aber Schluss.
Muss nämlich dann weg.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 12:48   #13 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Man das war ne harte Geburt.
Ich hatte da mit dem Math.abs echt
einen Denkfehler gehabt.
Sieht noch etwas abgehackt aus am
Schluss jeder gebremsten Bewegung,
aber darum muss ich mich evtl. später
bemühen. Das mit den Strichdicken
, dass sie am Ende etwas dicker werden
passiert nicht bei allen Strichstärken.
Da muss man auch mal nach schauen.

ActionScript:
  1. var easing = 5;
  2. _root.createEmptyMovieClip("line", 1);
  3. with (_root.line) {
  4.     lineStyle(2, 0xFF0000);
  5. }
  6. ini = 2;
  7. //------------------------------------------
  8. function drawL(x0, y0, x1, y1, x2, y2, x3, y3, x4, y4) {
  9.     _root.line.moveTo(x0, y0);
  10.     ar = arguments;
  11.     _root.line.onEnterFrame = function() {
  12.         if ((x0 > x1 - 6 && x0 < x1 + 6) && (y0 > y1 - 6 && y0 < y1 + 6)) {
  13.             this.lineTo(x1, y1);
  14.             drawL(ar[ini], ar[ini + 1], ar[ini + 2], ar[ini + 3], ar[ini + 4], ar[ini + 5], ar[ini + 6], ar[ini + 7]);
  15.         } else {
  16.             x0 += Math.round((x1 - x0) / easing);
  17.             y0 += Math.round((y1 - y0) / easing);
  18.             this.lineTo(x0, y0);
  19.         }
  20.     };
  21. }
  22. //------------------------------------------
  23. drawL(0, 0, 200, 0, 200, 200, 0, 200, 0, 0);
Angehängte Dateien
Dateityp: zip randomStrich2.zip (552 Bytes, 11x aufgerufen)
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 12:59   #14 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
So musste es noch korrigieren,
damit das onEnterFrame zum Schluss
gelöscht wird.
ActionScript:
  1. var easing = 5;
  2. _root.createEmptyMovieClip("line", 1);
  3. with (_root.line) {
  4.     lineStyle(5, 0xFF0000);
  5. }
  6. ini = 2;
  7. //------------------------------------------
  8. function drawL(x0, y0, x1, y1, x2, y2, x3, y3, x4, y4) {
  9.     _root.line.moveTo(x0, y0);
  10.     ar = arguments;
  11.     _root.line.onEnterFrame = function() {
  12.         if ((x0 > x1 - 6 && x0 < x1 + 6) && (y0 > y1 - 6 && y0 < y1 + 6)) {
  13.             this.lineTo(x1, y1);
  14.             drawL(ar[ini], ar[ini + 1], ar[ini + 2], ar[ini + 3], ar[ini + 4], ar[ini + 5], ar[ini + 6], ar[ini + 7]);
  15.         } else {
  16.             ar[ini] == undefined ? delete this.onEnterFrame : null;
  17.             x0 += Math.round((x1 - x0) / easing);
  18.             y0 += Math.round((y1 - y0) / easing);
  19.             this.lineTo(x0, y0);
  20.         }
  21.     };
  22. }
  23. //------------------------------------------
  24. drawL(0, 0, 200, 0, 200, 200, 0, 200, 0, 0);
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------
thebiz ist offline   Mit Zitat antworten
Alt 21-02-2005, 13:18   #15 (permalink)
All-rounder
 
Benutzerbild von thebiz
 
Registriert seit: Mar 2004
Ort: Bayerische Rhön
Beiträge: 2.507
Also irgendein Fehler ist noch drinnen.
Wenn man als Startwert keine Null
eingibt, dann zeichnet er zum Schluss
zu Null zurück.
Ich muss jetzt aber erst mal weg.

edit:
Du kannst es ja derweil auch so machen,
dass Du 4 mal den einzelnen Strich
aufrufst, mit den entsprechenden
Koordinaten. Musst halt 4 line Clips erstellen etc.
__________________

--------------------------------
Ich klicke, ergo bin ich. (me)
--------------------------------

Geändert von thebiz (21-02-2005 um 13:21 Uhr)
thebiz 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:08 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele