Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 16-08-2003, 14:17   #1 (permalink)
Neuer User
 
Benutzerbild von dark_fire
 
Registriert seit: Apr 2003
Ort: Schweiz
Beiträge: 47
eine figur per as zeichnen lassen

hey!

kann mir jemand bei einem as helfen!?

ich möchte ein rechteck mit einem as zeichen, bei dem ich die geschwindigkeit , linienstärke und farbe, direkt im as definieren kann. ist das möglich?

greets

dark_fire
dark_fire ist offline   Mit Zitat antworten
Alt 16-08-2003, 14:36   #2 (permalink)
HAY
Neuer User
 
Benutzerbild von HAY
 
Registriert seit: Aug 2002
Ort: Faust-Stadt
Beiträge: 2.577
ja ist möglich.hast du schon einen anfang.

[edit]
kleines beispiel:
ActionScript:
  1. this.createEmptyMovieClip( "rechteck", 1 );
  2.     with (_root.rechteck){
  3.         beginFill (0x0000FF, 50);
  4.         lineStyle (2, 0xFF0000, 100);
  5.         moveTo (0, 0);
  6.         lineTo (50, 0);
  7.         lineTo (50, 50);
  8.         lineTo (0, 50);
  9.         lineTo (0, 0);
  10.         endFill();
  11. }
  12. this.rechteck.onEnterFrame = function() {
  13.         this._x+=1
  14. }
__________________
gruß Harry

Geändert von HAY (16-08-2003 um 14:42 Uhr)
HAY ist offline   Mit Zitat antworten
Alt 16-08-2003, 15:05   #3 (permalink)
Neuer User
 
Benutzerbild von dark_fire
 
Registriert seit: Apr 2003
Ort: Schweiz
Beiträge: 47
leider nicht. ich habe in der flash hilfe nachgeschaut , doch dort habe ich keinen ansatz für meine idee gefunden...?

ich habe dein as getestet, es ist nicht das was ich eigendlich gemeint habe, dein as zeichnet ein rechteck und dies bewegt sich dann über die szene.

ich habe es mir eigendlich so vorgestellt, dass man sieht wie es das rechteck zeichnet, linie um line und dies an einem fixen punkt.
wäre dies auch möglich?

besten dank im voraus.


greets

dark_fire
dark_fire ist offline   Mit Zitat antworten
Alt 16-08-2003, 15:20   #4 (permalink)
Achim Math.PI
 
Benutzerbild von bloba
 
Registriert seit: Jul 2001
Ort: cool Colonia
Beiträge: 11.642
also zieh ein 10 px qaudrat auf
und nen mc
PHP-Code:
posx = [000000, -0, -01020, -10, -000000];
posy = [0, -10, -20, -30, -30, -50, -30, -30, -30, -20, -1001030102030];
mc._alpha 20;
mc.onEnterFrame = function() {
    
this.duplicateMovieClip("emce"+ii);
    ++
i;
    
this._x posx[i];
    
this._y posy[i];
}; 
vielspass
__________________
gruß bloba

2 x onkel² b_d
bloba ist offline   Mit Zitat antworten
Alt 16-08-2003, 15:36   #5 (permalink)
Neuer User
 
Registriert seit: Dec 2002
Ort: mars
Beiträge: 90
hi,
is nurn schneller ansatz für ein rechteck, vielleicht hilfts
ActionScript:
  1. function makre(breit, hoch, schritt) {
  2.     var mc = _root.createEmptyMovieClip("recht", 1);
  3.     tellTarget (mc) {
  4.         lineStyle(2, 0x000000, 100);
  5.         moveTo(0, 0);
  6.         _x = _y=150;
  7.         x = y=0;
  8.         x1 = breit;
  9.         y1 = hoch;
  10.         onEnterFrame = function () {
  11.             tellTarget (this) {
  12.                 if (x<breit) {
  13.                     lineTo(x += schritt, 0);
  14.                 } else if (x>=breit && y<hoch) {
  15.                     lineTo(x, y += schritt);
  16.                 } else if (x>=breit && y>=hoch && x1>0) {
  17.                     lineTo(x1 -= schritt, hoch);
  18.                 } else if (x>=breit && y>=hoch && x1<=0 && y1>0) {
  19.                     lineTo(x1, y1 -= schritt);
  20.                 } else {
  21.                     delete onEnterFrame;
  22.                 }
  23.             }
  24.         };
  25.     }
  26. }
  27. makre(50, 30, 2);

hicks
whiskeykid
whiskeycola ist offline   Mit Zitat antworten
Alt 16-08-2003, 15:41   #6 (permalink)
Achim Math.PI
 
Benutzerbild von bloba
 
Registriert seit: Jul 2001
Ort: cool Colonia
Beiträge: 11.642
@WC ich habs mal in MX um geschrieben
PHP-Code:
function makre(breithochschritt) {
    var 
mc _root.createEmptyMovieClip("recht"1);
    
with (mc) {
        
lineStyle(20x000000100);
        
moveTo(00);
        
_x _y=150;
        
y=0;
        
x1 breit;
        
y1 hoch;
        
onEnterFrame = function () {
            
with (mc) {
                if (
x<breit) {
                    
lineTo(+= schritt0);
                } else if (
x>=breit && y<hoch) {
                    
lineTo(x+= schritt);
                } else if (
x>=breit && y>=hoch && x1>0) {
                    
lineTo(x1 -= schritthoch);
                } else if (
x>=breit && y>=hoch && x1<=&& y1>0) {
                    
lineTo(x1y1 -= schritt);
                } else {
                    
delete onEnterFrame;
                }
            }
        };
    }
}
makre(50302); 
__________________
gruß bloba

2 x onkel² b_d
bloba ist offline   Mit Zitat antworten
Alt 16-08-2003, 15:45   #7 (permalink)
Neuer User
 
Registriert seit: Dec 2002
Ort: mars
Beiträge: 90
hi bloba,
das war von mir schon so gedacht, "with" is leider sehr langsam ,
ich wollte nur performance sparen - gewöhnt man sich überall an
-thnx anyway

hikcskid
whiskeycola ist offline   Mit Zitat antworten
Alt 16-08-2003, 16:16   #8 (permalink)
Neuer User
 
Registriert seit: Jun 2001
Ort: Zürich
Beiträge: 1.776
@whiskeycola:
klasse! aber noch n bisschen buggy: stell mal die schrittlänge so ein, dass sie nicht durch die rechteckmasse teilbar ist:
ActionScript:
  1. function makre(breit, hoch, schritt) {
  2.         var mc = _root.createEmptyMovieClip("recht", 1);
  3.         tellTarget (mc) {
  4.                 lineStyle(.25, 0x000000, 100);
  5.                 moveTo(0, 0);
  6.                 _x = _y=150;
  7.                 x = y=0;
  8.                 x1 = breit;
  9.                 y1 = hoch;
  10.                 onEnterFrame = function () {
  11.                         tellTarget (this) {
  12.                                 if (x<breit) {
  13.                                         lineTo(x += schritt, 0);
  14.                                 } else if (x>=breit && y<hoch) {
  15.                                         lineTo(x, y += schritt);
  16.                                 } else if (x>=breit && y>=hoch && x1>0) {
  17.                                         lineTo(x1 -= schritt, hoch);
  18.                                 } else if (x>=breit && y>=hoch && x1<=0 && y1>0) {
  19.                                         lineTo(x1, y1 -= schritt);
  20.                                 } else {
  21.                                         delete onEnterFrame;
  22.                                 }
  23.                         }
  24.                 };
  25.         }
  26. }
  27. makre(150, 30, 7);
fresh ist offline   Mit Zitat antworten
Alt 16-08-2003, 16:44   #9 (permalink)
Neuer User
 
Benutzerbild von dark_fire
 
Registriert seit: Apr 2003
Ort: Schweiz
Beiträge: 47
Hey!

besten dank! die bemerkung von fresh ist noch interessant, denn so ist das ergebnis nicht mehr das erwünschte...

was ich noch fragen möchte, könnte mann den as nicht so aufbauen, dass man auch freie formen zeichnen lassen kann?
so das man die figur in etwa so angeben kann:

b,h, x, y

0, 210.9,45,96;
157,0,45,306.9;
56,156.9,202,141;
213;45;45,96

so das es diese linien nach zeichnet?

greets

dark_fire
dark_fire ist offline   Mit Zitat antworten
Alt 16-08-2003, 18:12   #10 (permalink)
{flasher}
 
Benutzerbild von Majo
 
Registriert seit: Mar 2003
Ort: on water
Beiträge: 2.823
hier mein vorschlag
ActionScript:
  1. function drawRect(startx, starty, breite, hoehe, step, linecolor, dicke) {
  2.     var mc = _root.createEmptyMovieClip("rectacle", 1);
  3.     with (rectacle) {
  4.         lineStyle(dicke, linecolor, 100);
  5.         _x = startx;
  6.         _y = starty;
  7.         var x1 = breite;
  8.         var y1 = hoehe; 
  9.         onEnterFrame = function () {            
  10.             if (x<breite) {
  11.                 lineTo(x += step, 0);
  12.             }
  13.             if (x>=breite && y<hoehe) {
  14.                 lineTo(x, y += step);
  15.             }            
  16.             if (x>=breite && y>=hoehe && x1>0) {
  17.                 lineTo(x1 -= step, hoehe);
  18.             }
  19.             if (x>=breite && y>=hoehe && x1<=0 && y1>0) {
  20.                 lineTo(x1, y1 -= step);      
  21.             }
  22.             if(y1 == 0){
  23.                 trace("the end");
  24.                 delete this.onEnterFrame;
  25.             }
  26.         }
  27.     }
  28. };   
  29. //startx, starty, breite, hoehe, step, linecolor, dicke
  30. drawRect(100,100, 50, 30, 2, 0xff0000, 4);

hi bloba
__________________
hang loose
Majo ist offline   Mit Zitat antworten
Alt 16-08-2003, 18:20   #11 (permalink)
Banned
 
Registriert seit: Jan 2002
Beiträge: 4.777
http://abos-soft.com/zeichnen.html

so in der art sollte das dann wohl aussehen
bie einer weiter entwickelten version lässt sich der käse dann in db speichern und wieder malen

also:
zeichen
dann den ersten roten balken klixen
und dann den 2ten
the-ox ist offline   Mit Zitat antworten
Alt 16-08-2003, 18:28   #12 (permalink)
Neuer User
 
Registriert seit: Dec 2002
Ort: mars
Beiträge: 90
sodala,
ich schmeiss ma schnell alles zusammen
ActionScript:
  1. function makre(startx, starty, breit, hoch, schritt, linecolor, dicke) {
  2.     var mc = _root.createEmptyMovieClip("recht", 1);
  3.     tellTarget (mc) {
  4.         lineStyle(dicke, linecolor, 100);
  5.         moveTo(0, 0);
  6.         _x = startx;
  7.         _y = starty;
  8.         x = y=0;
  9.         posx = [];
  10.         posy = [];
  11.         langx = x1=Math.ceil(breit/schritt);
  12.         langy = y1=Math.ceil(hoch/schritt);
  13.         for (var i = 0; i<=langx; i++) {
  14.             var temp = i*schritt;
  15.             posx[i] = temp<=breit ? temp : breit;
  16.         }
  17.         for (var i = 0; i<=langy; i++) {
  18.             var temp = i*schritt;
  19.             posy[i] = temp<=hoch ? temp : hoch;
  20.         }
  21.         onEnterFrame = function () {
  22.             tellTarget (this) {
  23.                 if (x<=langx) {
  24.                     lineTo(posx[x], 0);
  25.                     x++;
  26.                 } else if (x>langx && y<=langy) {
  27.                     lineTo(breit, posy[y]);
  28.                     y++;
  29.                 } else if (x>langx && y>langy && x1>=0) {
  30.                     lineTo(posx[x1], hoch);
  31.                     x1--;
  32.                 } else if (x>langx && y>langy && x1<=-1 && y1>=0) {
  33.                     lineTo(0, posy[y1]);
  34.                     y1--;
  35.                 } else {
  36.                     delete onEnterFrame;
  37.                     trace("done");
  38.  
  39.                 }
  40.             }
  41.         };
  42.     }
  43. }
  44. makre(100, 100, 283, 347, 7, 0xff0000, 4);

hicks
whiskeykid
whiskeycola ist offline   Mit Zitat antworten
Alt 16-08-2003, 19:23   #13 (permalink)
Neuer User
 
Benutzerbild von dark_fire
 
Registriert seit: Apr 2003
Ort: Schweiz
Beiträge: 47
hey! danke !

diese variante von "whiskeycola" funktioniert jetzt tadellose.

zum betrag von" the-ox":

so hatte ich es nicht gedacht, ich dachte schon so wie die lösung von "whiskeycola" nur mit einer anderen form z.b. trapez oder 6eck oder so..
wenn ich das richtig sehe müsste man diesen as praktisch neu aufbauen wenn man eine andere form möchte. mein gedanke wäre, dass man nur noch die linien oder ecken im as definieren müsste.

greets

dark_fire
dark_fire ist offline   Mit Zitat antworten
Alt 16-08-2003, 19:33   #14 (permalink)
Banned
 
Registriert seit: Jan 2002
Beiträge: 4.777
schon klar
aber bei meinem teil kannst du irgendwas vorher malen und das wird dann wieder gegeben - is doch viel dynamischer
the-ox ist offline   Mit Zitat antworten
Alt 17-08-2003, 10:15   #15 (permalink)
Neuer User
 
Benutzerbild von dark_fire
 
Registriert seit: Apr 2003
Ort: Schweiz
Beiträge: 47
du hast recht deine variante ist dynamischer. mich interessiert aber eher die variante von "whiskeycola" , den von dieser kann ich dann später vieles ableiten. was mich noch interessieren würde wie man diese figur:

http://www.futurefun.ch/form.gif

mit whiskeycola's variante zeichnen kann.


greets

dark_fire
dark_fire 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 06:58 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele