Zurück   Flashforum > Flash > ActionScript > Softwarearchitektur und Entwurfsmuster

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 22-03-2003, 10:24   #1 (permalink)
...
 
Registriert seit: Oct 2002
Ort: Nürnberg
Beiträge: 3.611
Bisschen rumgebastelt

Hi, hab mal was kl. gebastelt, da ich heut frueh nichts besseres zu tun hatte
3 Kreise erstellen -> Instanznamen: point1, point2, point3.
3 linien von (0|0) bis (100|100) -> Instanznamen: line1, line2, line3.

ActionScript:
  1. _root.speed=100;
  2. _root.wechsel=1000
  3.  
  4.  
  5.  //POINT1 -------------------------------------------------------------------------
  6. newcoord1 = function() {
  7.         _root.newx1X = Math.round(Math.random() *400)-100;
  8.         _root.newx1Y = Math.round(Math.random() *400)-50;
  9. }
  10. setInterval(newcoord1,_root.wechsel);
  11. /////////////////////////////////////////////////////////////////////////////
  12. this.point1.onEnterFrame=function(){
  13.     _root.line1._x=this._x;
  14.     _root.line1._y=this._y;
  15.     _root.line1._xscale=_root.point2._x-_root.point1._x
  16.     _root.line1._yscale=_root.point2._y-_root.point1._y
  17.     this._x += Math.ceil((_root.newx1X - this._x) / _root.speed);
  18.     this._y += Math.ceil((_root.newx1Y - this._y) / _root.speed);
  19. }
  20. ///////////////////////////////////////////////////////////////////////////////
  21. ///////////////////////////////////////////////////////////////////////////////
  22. //POINT2 -------------------------------------------------------------------------
  23. newcoord2 = function() {
  24.         _root.newx2X = Math.round(Math.random() * 400)-100;
  25.         _root.newx2Y = Math.round(Math.random() *400)-50;
  26. }
  27. setInterval(newcoord2,_root.wechsel);
  28. ////////////////////////////////////////////////////////////////////////////////
  29. this.point2.onEnterFrame=function(){
  30.     _root.line2._x=this._x;
  31.     _root.line2._y=this._y;
  32.     _root.line2._xscale=_root.point3._x-_root.point2._x
  33.     _root.line2._yscale=_root.point3._y-_root.point2._y
  34.     this._x += Math.ceil((_root.newx2X - this._x) / _root.speed);
  35.     this._y += Math.ceil((_root.newx2Y - this._y) / _root.speed);
  36. }
  37. ////////////////////////////////////////////////////////////////////////////////
  38. ////////////////////////////////////////////////////////////////////////////////
  39. //POINT3 -------------------------------------------------------------------------
  40. newcoord3 = function() {
  41.         _root.newx3X = Math.round(Math.random() *400)-100;
  42.         _root.newx3Y = Math.round(Math.random() *400)-50;
  43. }
  44. setInterval(newcoord3,_root.wechsel);
  45. ////////////////////////////////////////////////////////////////////////////////
  46. this.point3.onEnterFrame=function(){
  47.     _root.line3._x=this._x;
  48.     _root.line3._y=this._y;
  49.     _root.line3._xscale=_root.point1._x-_root.point3._x
  50.     _root.line3._yscale=_root.point1._y-_root.point3._y
  51.     this._x += Math.ceil((_root.newx3X - this._x) / _root.speed);
  52.     this._y += Math.ceil((_root.newx3Y - this._y) / _root.speed);
  53. }

greez
thorben84
thorben.schmitt ist offline   Mit Zitat antworten
Alt 22-03-2003, 11:19   #2 (permalink)
Trainman
 
Benutzerbild von Hamster2k
 
Registriert seit: Sep 2001
Ort: Wien, Österreich
Beiträge: 1.324
Nett!
Hier nochmal zum Spannern
MfG
__________________
So much to learn and so little time.

Ich liebe dieses Forum!!
Hamster2k ist offline   Mit Zitat antworten
Alt 22-03-2003, 11:31   #3 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Ort: Aachen
Beiträge: 1.081
schön schön.

hier noch ne Variante:
klick
__________________
G.M. | working @ source lounge
georgexp ist offline   Mit Zitat antworten
Alt 23-03-2003, 17:10   #4 (permalink)
...
 
Registriert seit: Oct 2002
Ort: Nürnberg
Beiträge: 3.611
ok, habs mal ein bischen erweitert:
ActionScript:
  1. _root.beschArr = ["", "a", "b", "c", "d", "e", "f"];
  2. _root.zielArr = ["", "A", "B", "C", "D", "E", "F"];
  3. _root.wechsel = 1000;
  4. _root.speed = 50;
  5. _root.wertX = 400;
  6. _root.wertY = 300;
  7. for (i=1; i<=6; i++) {
  8.     _root["point"+i].beschriftung = _root.beschArr[i];
  9. }
  10. //POINT1 -------------------------------------------------------------------------
  11. newcoord1 = function () {
  12.     _root.newx1X = Math.round(Math.random()*_root.wertX);
  13.     _root.newx1Y = Math.round(Math.random()*_root.wertY);
  14. };
  15. setInterval(newcoord1, _root.wechsel);
  16. /////////////////////////////////////////////////////////////////////////////
  17. this.point1.onEnterFrame = function() {
  18.     _root.line1._x = this._x;
  19.     _root.line1._y = this._y;
  20.     _root.line1._xscale = _root.point2._x-_root.point1._x;
  21.     _root.line1._yscale = _root.point2._y-_root.point1._y;
  22.     this._x += Math.ceil((_root.newx1X-this._x)/_root.speed);
  23.     this._y += Math.ceil((_root.newx1Y-this._y)/_root.speed);
  24. };
  25. ///////////////////////////////////////////////////////////////////////////////
  26. ///////////////////////////////////////////////////////////////////////////////
  27. //POINT2 -------------------------------------------------------------------------
  28. newcoord2 = function () {
  29.     _root.newx2X = Math.round(Math.random()*_root.wertX);
  30.     _root.newx2Y = Math.round(Math.random()*_root.wertY);
  31. };
  32. setInterval(newcoord2, _root.wechsel);
  33. ////////////////////////////////////////////////////////////////////////////////
  34. this.point2.onEnterFrame = function() {
  35.     _root.line2._x = this._x;
  36.     _root.line2._y = this._y;
  37.     _root.line2._xscale = _root.point3._x-_root.point2._x;
  38.     _root.line2._yscale = _root.point3._y-_root.point2._y;
  39.     this._x += Math.ceil((_root.newx2X-this._x)/_root.speed);
  40.     this._y += Math.ceil((_root.newx2Y-this._y)/_root.speed);
  41. };
  42. ////////////////////////////////////////////////////////////////////////////////
  43. ////////////////////////////////////////////////////////////////////////////////
  44. //POINT3 -------------------------------------------------------------------------
  45. newcoord3 = function () {
  46.     _root.newx3X = Math.round(Math.random()*_root.wertX);
  47.     _root.newx3Y = Math.round(Math.random()*_root.wertY);
  48. };
  49. setInterval(newcoord3, _root.wechsel);
  50. ////////////////////////////////////////////////////////////////////////////////
  51. this.point3.onEnterFrame = function() {
  52.     _root.line3._x = this._x;
  53.     _root.line3._y = this._y;
  54.     _root.line3._xscale = _root.point4._x-_root.point3._x;
  55.     _root.line3._yscale = _root.point4._y-_root.point3._y;
  56.     this._x += Math.ceil((_root.newx3X-this._x)/_root.speed);
  57.     this._y += Math.ceil((_root.newx3Y-this._y)/_root.speed);
  58. };
  59. //POINT4 -------------------------------------------------------------------------
  60. newcoord4 = function () {
  61.     _root.newx4X = Math.round(Math.random()*_root.wertX);
  62.     _root.newx4Y = Math.round(Math.random()*_root.wertY);
  63. };
  64. setInterval(newcoord4, _root.wechsel);
  65. ////////////////////////////////////////////////////////////////////////////////
  66. this.point4.onEnterFrame = function() {
  67.     _root.line4._x = this._x;
  68.     _root.line4._y = this._y;
  69.     _root.line4._xscale = _root.point5._x-_root.point4._x;
  70.     _root.line4._yscale = _root.point5._y-_root.point4._y;
  71.     this._x += Math.ceil((_root.newx4X-this._x)/_root.speed);
  72.     this._y += Math.ceil((_root.newx4Y-this._y)/_root.speed);
  73. };
  74. //POINT5 -------------------------------------------------------------------------
  75. newcoord5 = function () {
  76.     _root.newx5X = Math.round(Math.random()*_root.wertX);
  77.     _root.newx5Y = Math.round(Math.random()*_root.wertY);
  78. };
  79. setInterval(newcoord5, _root.wechsel);
  80. ////////////////////////////////////////////////////////////////////////////////
  81. this.point5.onEnterFrame = function() {
  82.     _root.line5._x = this._x;
  83.     _root.line5._y = this._y;
  84.     _root.line5._xscale = _root.point6._x-_root.point5._x;
  85.     _root.line5._yscale = _root.point6._y-_root.point5._y;
  86.     this._x += Math.ceil((_root.newx5X-this._x)/_root.speed);
  87.     this._y += Math.ceil((_root.newx5Y-this._y)/_root.speed);
  88. };
  89. //POINT6 -------------------------------------------------------------------------
  90. newcoord6 = function () {
  91.     _root.newx6X = Math.round(Math.random()*_root.wertX);
  92.     _root.newx6Y = Math.round(Math.random()*_root.wertY);
  93. };
  94. setInterval(newcoord6, _root.wechsel);
  95. ////////////////////////////////////////////////////////////////////////////////
  96. this.point6.onEnterFrame = function() {
  97.     _root.line6._x = this._x;
  98.     _root.line6._y = this._y;
  99.     _root.line6._xscale = _root.point1._x-_root.point6._x;
  100.     _root.line6._yscale = _root.point1._y-_root.point6._y;
  101.     this._x += Math.ceil((_root.newx6X-this._x)/_root.speed);
  102.     this._y += Math.ceil((_root.newx6Y-this._y)/_root.speed);
  103. };
  104. // Vektorlaenge
  105. _root.laenge = function(ausgabeVektor, punkt1, punkt2) {
  106.     this[ausgabeVektor] = Math.round(Math.sqrt(Math.pow((Math.abs(_root[punkt1]._x-_root[punkt2]._x)), 2)+Math.pow((Math.abs(_root[punkt2]._y-_root[punkt1]._y)), 2)))+" px";
  107. };
  108. // Abstaende
  109. _root.dummy.onEnterFrame = function() {
  110.     _root.laenge("a_b", "point1", "point2");
  111.     _root.laenge("b_c", "point2", "point3");
  112.     _root.laenge("c_d", "point3", "point4");
  113.     _root.laenge("d_e", "point4", "point5");
  114.     _root.laenge("e_f", "point5", "point6");
  115.     _root.laenge("f_a", "point6", "point1");
  116.     for (i=1; i<=6; i++) {
  117.         // X
  118.         if (_root["newx"+i+"X"]<10) {
  119.             _root["ziel"+_root.zielArr[i]+"x"] = "00"+_root["newx"+i+"X"];
  120.         } else if (_root["newx"+i+"X"]<100) {
  121.             _root["ziel"+_root.zielArr[i]+"x"] = "0"+_root["newx"+i+"X"];
  122.         } else if (_root["newx"+i+"X"]>100) {
  123.             _root["ziel"+_root.zielArr[i]+"x"] = _root["newx"+i+"X"];
  124.         }
  125.         // Y
  126.         if (_root["newx"+i+"Y"]<10) {
  127.             _root["ziel"+_root.zielArr[i]+"y"] = "00"+_root["newx"+i+"Y"];
  128.         } else if (_root["newx"+i+"y"]<100) {
  129.             _root["ziel"+_root.zielArr[i]+"y"] = "0"+_root["newx"+i+"Y"];
  130.         } else if (_root["newx"+i+"Y"]>100) {
  131.             _root["ziel"+_root.zielArr[i]+"y"] = _root["newx"+i+"Y"];
  132.         }
  133.     }
  134.  
  135. };


anschauen

greez
thorben84
thorben.schmitt ist offline   Mit Zitat antworten
Alt 23-03-2003, 19:57   #5 (permalink)
Freelancer
 
Benutzerbild von komashooter
 
Registriert seit: Oct 2001
Ort: Germany - Berlin
Beiträge: 1.777
Question

eine FLA Datei wäre sachon besser

ich werd aus dein as nicht so recht schlau ..

_root.line1._ zum Beispiel was is das

_root.line1._ .. wird jedenfalls nicht mit as erstellt
komashooter ist offline   Mit Zitat antworten
Alt 23-03-2003, 20:05   #6 (permalink)
...
 
Registriert seit: Oct 2002
Ort: Nürnberg
Beiträge: 3.611
So, jetzt muss man nixx mehr zeichnen
ActionScript:
  1. // Copyright Thorben Schmitt
  2. // [email]ts@iconline.de[/email]
  3.  
  4. _root.wechsel = 1000;
  5. _root.speed = 100;
  6. _root.wertX = 400;
  7. _root.wertY = 300;
  8. for (i=1; i<=6; i++) {
  9.     // erzeugen der linien
  10.     _root.createEmptyMovieClip("line"+i, i);
  11.     with (_root["line"+i]) {
  12.         lineStyle(0, 0x000000, 100);
  13.         moveTo(0, 0);
  14.         lineTo(100, 100);
  15.     }
  16.     // erzeugen der punkt
  17.     _root.createEmptyMovieClip("point"+i, 7+i);
  18.     with (_root["point"+i]) {
  19.         beginFill(0x666666, 100);
  20.         moveTo(-5, -5);
  21.         lineTo(5, -5);
  22.         lineTo(5, 5);
  23.         lineTo(-5, 5);
  24.         endFill();
  25.     }
  26. }
  27. _root.createEmptyMovieClip("dummy", 999);
  28. //POINT1 -------------------------------------------------------------------------
  29. newcoord1 = function () {
  30.     _root.newx1X = Math.round(Math.random()*_root.wertX);
  31.     _root.newx1;
  32.     Y = Math.round(Math.random()*_root.wertY);
  33. };
  34. setInterval(newcoord1, _root.wechsel);
  35. /////////////////////////////////////////////////////////////////////////////
  36. this.point1.onEnterFrame = function() {
  37.     _root.line1._x = this._x;
  38.     _root.line1._y = this._y;
  39.     _root.line1._xscale = _root.point2._x-_root.point1._x;
  40.     _root.line1._yscale = _root.point2._y-_root.point1._y;
  41.     this._x += Math.ceil((_root.newx1X-this._x)/_root.speed);
  42.     this._y += Math.ceil((_root.newx1Y-this._y)/_root.speed);
  43. };
  44. ///////////////////////////////////////////////////////////////////////////////
  45. ///////////////////////////////////////////////////////////////////////////////
  46. //POINT2 -------------------------------------------------------------------------
  47. newcoord2 = function () {
  48.     _root.newx2X = Math.round(Math.random()*_root.wertX);
  49.     _root.newx2Y = Math.round(Math.random()*_root.wertY);
  50. };
  51. setInterval(newcoord2, _root.wechsel);
  52. ////////////////////////////////////////////////////////////////////////////////
  53. this.point2.onEnterFrame = function() {
  54.     _root.line2._x = this._x;
  55.     _root.line2._y = this._y;
  56.     _root.line2._xscale = _root.point3._x-_root.point2._x;
  57.     _root.line2._yscale = _root.point3._y-_root.point2._y;
  58.     this._x += Math.ceil((_root.newx2X-this._x)/_root.speed);
  59.     this._y += Math.ceil((_root.newx2Y-this._y)/_root.speed);
  60. };
  61. ////////////////////////////////////////////////////////////////////////////////
  62. ////////////////////////////////////////////////////////////////////////////////
  63. //POINT3 -------------------------------------------------------------------------
  64. newcoord3 = function () {
  65.     _root.newx3X = Math.round(Math.random()*_root.wertX);
  66.     _root.newx3Y = Math.round(Math.random()*_root.wertY);
  67. };
  68. setInterval(newcoord3, _root.wechsel);
  69. ////////////////////////////////////////////////////////////////////////////////
  70. this.point3.onEnterFrame = function() {
  71.     _root.line3._x = this._x;
  72.     _root.line3._y = this._y;
  73.     _root.line3._xscale = _root.point4._x-_root.point3._x;
  74.     _root.line3._yscale = _root.point4._y-_root.point3._y;
  75.     this._x += Math.ceil((_root.newx3X-this._x)/_root.speed);
  76.     this._y += Math.ceil((_root.newx3Y-this._y)/_root.speed);
  77. };
  78. //POINT4 -------------------------------------------------------------------------
  79. newcoord4 = function () {
  80.     _root.newx4X = Math.round(Math.random()*_root.wertX);
  81.     _root.newx4Y = Math.round(Math.random()*_root.wertY);
  82. };
  83. setInterval(newcoord4, _root.wechsel);
  84. ////////////////////////////////////////////////////////////////////////////////
  85. this.point4.onEnterFrame = function() {
  86.     _root.line4._x = this._x;
  87.     _root.line4._y = this._y;
  88.     _root.line4._xscale = _root.point5._x-_root.point4._x;
  89.     _root.line4._yscale = _root.point5._y-_root.point4._y;
  90.     this._x += Math.ceil((_root.newx4X-this._x)/_root.speed);
  91.     this._y += Math.ceil((_root.newx4Y-this._y)/_root.speed);
  92. };
  93. //POINT5 -------------------------------------------------------------------------
  94. newcoord5 = function () {
  95.     _root.newx5X = Math.round(Math.random()*_root.wertX);
  96.     _root.newx5Y = Math.round(Math.random()*_root.wertY);
  97. };
  98. setInterval(newcoord5, _root.wechsel);
  99. ////////////////////////////////////////////////////////////////////////////////
  100. this.point5.onEnterFrame = function() {
  101.     _root.line5._x = this._x;
  102.     _root.line5._y = this._y;
  103.     _root.line5._xscale = _root.point6._x-_root.point5._x;
  104.     _root.line5._yscale = _root.point6._y-_root.point5._y;
  105.     this._x += Math.ceil((_root.newx5X-this._x)/_root.speed);
  106.     this._y += Math.ceil((_root.newx5Y-this._y)/_root.speed);
  107. };
  108. //POINT6 -------------------------------------------------------------------------
  109. newcoord6 = function () {
  110.     _root.newx6X = Math.round(Math.random()*_root.wertX);
  111.     _root.newx6Y = Math.round(Math.random()*_root.wertY);
  112. };
  113. setInterval(newcoord6, _root.wechsel);
  114. ////////////////////////////////////////////////////////////////////////////////
  115. this.point6.onEnterFrame = function() {
  116.     _root.line6._x = this._x;
  117.     _root.line6._y = this._y;
  118.     _root.line6._xscale = _root.point1._x-_root.point6._x;
  119.     _root.line6._yscale = _root.point1._y-_root.point6._y;
  120.     this._x += Math.ceil((_root.newx6X-this._x)/_root.speed);
  121.     this._y += Math.ceil((_root.newx6Y-this._y)/_root.speed);
  122. };

greez
thorben84

Geändert von thorben.schmitt (23-03-2003 um 20:31 Uhr)
thorben.schmitt ist offline   Mit Zitat antworten
Alt 24-03-2003, 08:00   #7 (permalink)
www.penck.de
 
Benutzerbild von borisp
 
Registriert seit: Jan 2002
Ort: Wiesbaden / Mainz-Kastel
Beiträge: 926
Mal ein wenig gekürzt um das gleiche Ergebnis zu erzielen:

ActionScript:
  1. _root.wechsel = 1000;
  2. _root.speed = 100;
  3. _root.wertX = 400;
  4. _root.wertY = 300;
  5.  
  6. movieclip.prototype.ani = function(lName,p1,p2,x1,y1) {
  7.     _root[lName].clear();
  8.     _root[lName].lineStyle(0);
  9.     _root[lName].moveTo(_root[p1]._x,_root[p1]._y);
  10.     _root[lName].lineTo(_root[p2]._x,_root[p2]._y);
  11.     this._x += Math.ceil((_root[x1]-this._x)/_root.speed);
  12.     this._y += Math.ceil((_root[y1]-this._y)/_root.speed);
  13. }
  14.  
  15. for (i=1; i<=6; i++) {
  16.         _root.createEmptyMovieClip("line"+i, i);
  17.         _root.createEmptyMovieClip("point"+i, 7+i);
  18.         with (_root["point"+i]) {
  19.                 beginFill(0x666666, 100);
  20.                 moveTo(-5, -5);
  21.                 lineTo(5, -5);
  22.                 lineTo(5, 5);
  23.                 lineTo(-5, 5);
  24.                 endFill();
  25.         }
  26.         _root["point"+i].anid = i;
  27.         _root["point"+i].onEnterFrame = function() {
  28.             this.anid2 = this.anid +1;
  29.             if(this.anid2 == 7) this.anid2 = 1;
  30.             this.ani("line"+this.anid,"point"+this.anid2,"point"+this.anid,"newx"+this.anid+"X","newx"+this.anid+"Y");
  31.         };
  32.         _root["newcoord"+i] = function (v) {
  33.             _root["newx"+v+"X"] = Math.round(Math.random()*_root.wertX);
  34.             _root["newx"+v+"Y"] = Math.round(Math.random()*_root.wertY);
  35.         };
  36.         setInterval(_root["newcoord"+i], _root.wechsel, i);
  37.  
  38. }
  39. _root.createEmptyMovieClip("dummy", 999);
borisp 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 12:56 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele