Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 30-01-2005, 20:40   #1 (permalink)
Neuer User
 
Benutzerbild von suicidesquirrel
 
Registriert seit: Jan 2004
Ort: Hannover, Germany
Beiträge: 144
Growing Poly von Bokel

hallo, hab mir ma aus nem thread
des hier (growing poly von bokel) gesaugt,
un da ich nu kein profi bin würd ich gerne wissen,
wie man denn bei der linie die farbe und den alpha wert
ändern kann. mussich dem mc ne farbe zuweisen? hab
n bissl rumprobiert aber komm irgendwie nich drauf.
danke schonma!!

ActionScript:
  1. // MX: GrowingPoly
  2. // zeichnet ein polygon aus "wachsenden" linien
  3. // von ralf bokelberg 05/2002 qlod.com
  4. function GrowingPoly(mc, speed, ms, coords) {
  5.     //object anlegen und parameter abspeichern
  6.     //in mc werden die linien gezeichnet
  7.     //speed gibt an, wie schnell die linie gezeichnet werden soll
  8.     //ms gibt an, wie haeufig das polygon upgedatet werden soll
  9.     //in coords sind die koordinaten im format [x1,y1,x2,y2,x3,y3,...]
  10.     this.mc = mc;
  11.     this.speed = speed || 1;
  12.     this.ms = ms || 100;
  13.     this.coords = coords;
  14.     this.intervalHandle = -1;
  15.     this.coordIdx = 2;
  16.     this.x = this.x1=this.x2=this.coords[0];
  17.     this.y = this.y1=this.y2=this.coords[1];
  18.     this.xAdd = this.yAdd=this.count=0;
  19. }
  20. GrowingPoly.prototype.draw = function() {
  21.     //wenn wir nicht gerade zeichnen, dann koennen wir loslegen
  22.     //trace("GrowingPoly.draw");
  23.     if (this.intervalHandle == -1) {
  24.         this.nextLine();
  25.     } else {
  26.         trace("FEHLER: GrowingPoly.draw: Zeichnen war schon gestartet.");
  27.     }
  28. };
  29. GrowingPoly.prototype.nextLine = function() {
  30.     //hier werden die koordinaten der naechsten linie geholt
  31.     //und die intervalroutine gestartet
  32.     with (this) {
  33.         // wenn es noch koordinaten gibt
  34.         if (coordIdx<coords.length) {
  35.             x = x1=x2;
  36.             //die alten endkoordinaten sind die neuen startkoordinaten
  37.             y = y1=y2;
  38.             x2 = coords[coordIdx++];
  39.             //die neuen endkoordinaten holen
  40.             y2 = coords[coordIdx++];
  41.             var angle = Math.atan2(x2-x1, y2-y1);
  42.             //winkel der linie berechnen
  43.             xAdd = speed*Math.sin(angle);
  44.             //was wird pro aufruf von doDraw zur Linie addiert
  45.             yAdd = speed*Math.cos(angle);
  46.             var xCount = Math.abs(Math.floor((x2-x1)/xAdd)) || 0;
  47.             //wie oft muss addiert werden
  48.             var yCount = Math.abs(Math.floor((y2-y1)/yAdd)) || 0;
  49.             count = Math.max(xCount, yCount);
  50.             //einer der Werte koennte 0 sein                   
  51.             intervalHandle = setInterval(this, "doDraw", ms);
  52.             //intervallhandler starten
  53.         }
  54.     }
  55. };
  56. GrowingPoly.prototype.doDraw = function() {
  57.     //hier wird gemalt
  58.     //es werden jeweils alle linien die schon gezeichnet worden sind
  59.     //plus das aktuelle teilstueck gezeichnet
  60.     with (this) {
  61.         //wenn wir mit der linie fertig sind
  62.         if (--count<=0) {
  63.             x = x2;
  64.             //komplette linie zeichnen
  65.             y = y2;
  66.             clearInterval(intervalHandle);
  67.             //intervalHandler kann gelöscht werden
  68.             intervalHandle = -1;
  69.             this.nextLine();
  70.         } else {
  71.             //sonst weiter machen
  72.             x += xadd;
  73.             y += yadd;
  74.         }
  75.         mc.clear();
  76.         //vorhergehende linien loeschen
  77.         mc.lineStyle(0, 0);
  78.         //leider wird der style gleich mitgeloescht, also neu setzen
  79.         //wenn wir noch bei der ersten linie sind
  80.         //dann gehen wir einfach nur zur startposition
  81.         if (coordIdx<=4) {
  82.             mc.moveTo(x1, y1);
  83.         } else {
  84.             //sonst zeichnen wir erst alle linien bis zur aktuellen
  85.             var i = 2, x3 = coords[0], y3 = coords[1];
  86.             mc.moveTo(x3, y3);
  87.             while (i<coordIdx-2) {
  88.                 x3 = coords[i++];
  89.                 y3 = coords[i++];
  90.                 mc.lineTo(x3, y3);
  91.             }
  92.         }
  93.         mc.lineTo(x, y);
  94.         //und das aktuelle teilstueck nicht vergessen
  95.     }
  96. };
  97. //testaufruf: zeichne mir ein viereck
  98. gp = new GrowingPoly(createEmptyMovieClip("l2", 2), 1, 20, [100, 100, 100, 200/*, 200, 200, 200, 100, 100, 100*/]);
  99. gp.draw();
__________________
hahahahahahahahaha höhöhöhöhöhöhö muhahahahaha!
suicidesquirrel ist offline   Mit Zitat antworten
Alt 30-01-2005, 20:50   #2 (permalink)
Gelegenheits-DAU
 
Benutzerbild von TOAOTC
 
Registriert seit: May 2003
Ort: Schwerin - come to where the Hecht beißt
Beiträge: 187
Hallo suicidesquirrel,
ActionScript:
  1. mc.lineStyle(0, 0);

Gruß
TOAOTC ist offline   Mit Zitat antworten
Alt 30-01-2005, 20:58   #3 (permalink)
.
 
Registriert seit: May 2003
Ort: bayern
Beiträge: 1.117
du könntest die werte für lineStyle beim Erstellen des growingPoly mitgeben
ActionScript:
  1. meinMovieclip.lineStyle ([dicke[, rgb[, alpha]]])

ich hab da mal was vorbereitet...
ActionScript:
  1. // MX: GrowingPoly
  2. // zeichnet ein polygon aus "wachsenden" linien
  3. // von ralf bokelberg 05/2002 qlod.com
  4. function GrowingPoly(mc, speed, ms, coords,lineThick,lineCol,lineAlpha) {
  5.     //object anlegen und parameter abspeichern
  6.     //in mc werden die linien gezeichnet
  7.     //speed gibt an, wie schnell die linie gezeichnet werden soll
  8.     //ms gibt an, wie haeufig das polygon upgedatet werden soll
  9.     //in coords sind die koordinaten im format [x1,y1,x2,y2,x3,y3,...]
  10.     this.mc = mc;
  11.     this.speed = speed || 1;
  12.     this.ms = ms || 100;
  13.     this.coords = coords;
  14.     this.lineThick = lineThick;
  15.     this.lineCol = lineCol;
  16.     this.lineAlpha = lineAlpha;
  17.     this.intervalHandle = -1;
  18.     this.coordIdx = 2;
  19.     this.x = this.x1=this.x2=this.coords[0];
  20.     this.y = this.y1=this.y2=this.coords[1];
  21.     this.xAdd = this.yAdd=this.count=0;
  22. }
  23. GrowingPoly.prototype.draw = function() {
  24.     //wenn wir nicht gerade zeichnen, dann koennen wir loslegen
  25.     //trace("GrowingPoly.draw");
  26.     if (this.intervalHandle == -1) {
  27.         this.nextLine();
  28.     } else {
  29.         trace("FEHLER: GrowingPoly.draw: Zeichnen war schon gestartet.");
  30.     }
  31. };
  32. GrowingPoly.prototype.nextLine = function() {
  33.     //hier werden die koordinaten der naechsten linie geholt
  34.     //und die intervalroutine gestartet
  35.     with (this) {
  36.         // wenn es noch koordinaten gibt
  37.         if (coordIdx<coords.length) {
  38.             x = x1=x2;
  39.             //die alten endkoordinaten sind die neuen startkoordinaten
  40.             y = y1=y2;
  41.             x2 = coords[coordIdx++];
  42.             //die neuen endkoordinaten holen
  43.             y2 = coords[coordIdx++];
  44.             var angle = Math.atan2(x2-x1, y2-y1);
  45.             //winkel der linie berechnen
  46.             xAdd = speed*Math.sin(angle);
  47.             //was wird pro aufruf von doDraw zur Linie addiert
  48.             yAdd = speed*Math.cos(angle);
  49.             var xCount = Math.abs(Math.floor((x2-x1)/xAdd)) || 0;
  50.             //wie oft muss addiert werden
  51.             var yCount = Math.abs(Math.floor((y2-y1)/yAdd)) || 0;
  52.             count = Math.max(xCount, yCount);
  53.             //einer der Werte koennte 0 sein                   
  54.             intervalHandle = setInterval(this, "doDraw", ms);
  55.             //intervallhandler starten
  56.         }
  57.     }
  58. };
  59. GrowingPoly.prototype.doDraw = function() {
  60.     //hier wird gemalt
  61.     //es werden jeweils alle linien die schon gezeichnet worden sind
  62.     //plus das aktuelle teilstueck gezeichnet
  63.     with (this) {
  64.         //wenn wir mit der linie fertig sind
  65.         if (--count<=0) {
  66.             x = x2;
  67.             //komplette linie zeichnen
  68.             y = y2;
  69.             clearInterval(intervalHandle);
  70.             //intervalHandler kann gelöscht werden
  71.             intervalHandle = -1;
  72.             this.nextLine();
  73.         } else {
  74.             //sonst weiter machen
  75.             x += xadd;
  76.             y += yadd;
  77.         }
  78.         mc.clear();
  79.         //vorhergehende linien loeschen
  80.         mc.lineStyle(lineThick, lineCol, lineAlpha);
  81.         //leider wird der style gleich mitgeloescht, also neu setzen
  82.         //wenn wir noch bei der ersten linie sind
  83.         //dann gehen wir einfach nur zur startposition
  84.         if (coordIdx<=4) {
  85.             mc.moveTo(x1, y1);
  86.         } else {
  87.             //sonst zeichnen wir erst alle linien bis zur aktuellen
  88.             var i = 2, x3 = coords[0], y3 = coords[1];
  89.             mc.moveTo(x3, y3);
  90.             while (i<coordIdx-2) {
  91.                 x3 = coords[i++];
  92.                 y3 = coords[i++];
  93.                 mc.lineTo(x3, y3);
  94.             }
  95.         }
  96.         mc.lineTo(x, y);
  97.         //und das aktuelle teilstueck nicht vergessen
  98.     }
  99. };
  100. //testaufruf: zeichne mir ein viereck
  101. gp = new GrowingPoly(createEmptyMovieClip("l2", 2), 1, 20, [/*100, 100, 100, 200,*/ 200, 200, 200, 100, 100, 100], 2, 0xFF0000, 45);
  102. gp.draw();

greetings...
__________________
[mooseMash]
mooseMash ist offline   Mit Zitat antworten
Alt 30-01-2005, 21:01   #4 (permalink)
Neuer User
 
Benutzerbild von suicidesquirrel
 
Registriert seit: Jan 2004
Ort: Hannover, Germany
Beiträge: 144
wow, yeah, danke für die schnelle antwort...
hatte damit wohl noch net genug rumgespielt....

für die dies trotzdem interessiert:

ActionScript:
  1. mc.lineStyle(0, 0xFF0000, 50);

O = Dicke
0xFF0000 = Farbe
50 = Transparenz
__________________
hahahahahahahahaha höhöhöhöhöhöhö muhahahahaha!
suicidesquirrel ist offline   Mit Zitat antworten
Alt 30-01-2005, 21:04   #5 (permalink)
Neuer User
 
Benutzerbild von suicidesquirrel
 
Registriert seit: Jan 2004
Ort: Hannover, Germany
Beiträge: 144
=) oh da war noch jemand schneller,
danke nochmal!
__________________
hahahahahahahahaha höhöhöhöhöhöhö muhahahahaha!
suicidesquirrel 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 17:24 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele