Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 08-05-2004, 18:22   #1 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
Perfect As???

hallo,

nach vielem lesen, versuche ich jetzt meine erste seite so zu designen das der GANZE code in einem Keyframe liegt...
Und wollte mal wissen ob das so anstaendiger code ist.
Alles was es macht ist es ordned MCs an, bei mouse over spielt es ein MOV ab das in dem MC liegt, und bei klick....
Also, ist das der richige anfang?
ActionScript:
  1. stop();
  2. // SET SPEED
  3. ABOUT.speed = "12";
  4. ABOUT.speed2 = "5";
  5. PRODUCTS.speed = "12";
  6. PRODUCTS.speed2 = "5";
  7. TEAM.speed = "12";
  8. TEAM.speed2 = "5";
  9. ELSE.speed = "12";
  10. ELSE.speed2 = "5";
  11.  
  12.  
  13. // ABOUT
  14. ABOUT.onLoad = function(){
  15. ABOUT.gotoAndStop("ABOUT");
  16. ABOUT.workx = "197.7";
  17. ABOUT.worky = "225.8";
  18. ABOUT.workw = "230";
  19. ABOUT.workh = "270";
  20. }
  21. ABOUT.onEnterFrame = function(){
  22. ABOUT._x += (ABOUT.workx-ABOUT._x)/ABOUT.speed;
  23. ABOUT._y += (ABOUT.worky-ABOUT._y)/ABOUT.speed;
  24. ABOUT._width += (ABOUT.workw-ABOUT._width)/ABOUT.speed2;
  25. ABOUT._height += (ABOUT.workh-ABOUT._height)/ABOUT.speed2;
  26. }
  27. ABOUT.onRollOver = function(){
  28. ABOUT.ABOUTMOV.gotoAndPlay(2);
  29. }
  30. ABOUT.onRollOut = function(){
  31. ABOUT.ABOUTMOV.gotoAndStop(1);
  32. }
  33. ABOUT.onPress = function(){
  34. //ABOUT.worky = "-333";
  35. PRODUCTS.workx = "-333";
  36. TEAM.worky = "933";
  37. ELSE.workx = "933";
  38. this.workx = "400";
  39. this.worky = "295";
  40. this.workh = "500";
  41. this.workw = "395";
  42. }
  43.  
  44.  
  45. //PRODUCTS
  46. PRODUCTS.onLoad = function(){
  47. PRODUCTS.gotoAndStop("PRODUCTS");
  48. PRODUCTS.workx = "381.1";
  49. PRODUCTS.worky = "173.2";
  50. PRODUCTS.workw = "230";
  51. PRODUCTS.workh = "270";
  52. }
  53. PRODUCTS.onEnterFrame = function(){
  54. PRODUCTS._x += (PRODUCTS.workx-PRODUCTS._x)/PRODUCTS.speed;
  55. PRODUCTS._y += (PRODUCTS.worky-PRODUCTS._y)/PRODUCTS.speed;
  56. PRODUCTS._width += (PRODUCTS.workw-PRODUCTS._width)/PRODUCTS.speed2;
  57. PRODUCTS._height += (PRODUCTS.workh-PRODUCTS._height)/PRODUCTS.speed2;
  58. }
  59. PRODUCTS.onRollOver = function(){
  60. PRODUCTS.PRODUCTSMOV.gotoAndPlay(2);
  61. }
  62. PRODUCTS.onRollOut = function(){
  63. PRODUCTS.PRODUCTSMOV.gotoAndStop(1);
  64. }
  65. PRODUCTS.onPress = function(){
  66. ABOUT.worky = "-333";
  67. //PRODUCTS.workx = "-333";
  68. TEAM.worky = "933";
  69. ELSE.workx = "933";
  70. this.workx = "400";
  71. this.worky = "295";
  72. this.workh = "500";
  73. this.workw = "395";
  74. }
  75.  
  76.  
  77.  
  78.  
  79. //TEAM
  80. TEAM.onLoad = function(){
  81. TEAM.gotoAndStop("TEAM");
  82. TEAM.workx = "566.5";
  83. TEAM.worky = "255.6";
  84. TEAM.workw = "230";
  85. TEAM.workh = "270";
  86. }
  87. TEAM.onEnterFrame = function(){
  88. TEAM._x += (TEAM.workx-TEAM._x)/TEAM.speed;
  89. TEAM._y += (TEAM.worky-TEAM._y)/TEAM.speed;
  90. TEAM._width += (TEAM.workw-TEAM._width)/TEAM.speed2;
  91. TEAM._height += (TEAM.workh-TEAM._height)/TEAM.speed2;
  92. }
  93. TEAM.onRollOver = function(){
  94. TEAM.TEAMMOV.gotoAndPlay(2);
  95. }
  96. TEAM.onRollOut = function(){
  97. TEAM.TEAMMOV.gotoAndStop(1);
  98. }
  99. TEAM.onPress = function(){
  100. ABOUT.worky = "-333";
  101. PRODUCTS.workx = "-333";
  102. //TEAM.worky = "933";
  103. ELSE.workx = "933";
  104. this.workx = "400";
  105. this.worky = "295";
  106. this.workh = "500";
  107. this.workw = "395";
  108. }
  109.  
  110.  
  111.  
  112. //ELSE
  113. ELSE.onLoad = function(){
  114. ELSE.gotoAndStop("ELSE");
  115. ELSE.workx = "293.6";
  116. ELSE.worky = "396.7";
  117. ELSE.workw = "230";
  118. ELSE.workh = "270";
  119. }
  120. ELSE.onEnterFrame = function(){
  121. ELSE._x += (ELSE.workx-ELSE._x)/ELSE.speed;
  122. ELSE._y += (ELSE.worky-ELSE._y)/ELSE.speed;
  123. ELSE._width += (ELSE.workw-ELSE._width)/ELSE.speed2;
  124. ELSE._height += (ELSE.workh-ELSE._height)/ELSE.speed2;
  125. }
  126. ELSE.onRollOver = function(){
  127. ELSE.ELSEMOV.gotoAndPlay(2);
  128. }
  129. ELSE.onRollOut = function(){
  130. ELSE.ELSEMOV.gotoAndStop(1);
  131. }
  132. ELSE.onPress = function(){
  133. ABOUT.worky = "-333";
  134. PRODUCTS.workx = "-333";
  135. TEAM.worky = "933";
  136. //ELSE.workx = "933";
  137. this.workx = "400";
  138. this.worky = "295";
  139. this.workh = "500";
  140. this.workw = "395";
  141. }
  142.  
  143. // MOVS
  144. ABOUT.ABOUTMOV.onLoad = function(){
  145. ABOUT.ABOUTMOV._visible = true;
  146. }
  147. PRODUCTS.PRODUCTSMOV.onLoad = function(){
  148. PRODUCTS.PRODUCTSMOV._visible = true;
  149. }
  150. TEAM.TEAMMOV.onLoad = function(){
  151. TEAM.TEAMMOV._visible = true;
  152. }
  153. ELSE.ELSEMOV.onLoad = function(){
  154. ELSE.ELSEMOV._visible = true;
  155. }

Geändert von nxfxcom (09-05-2004 um 09:28 Uhr)
nxfxcom ist offline   Mit Zitat antworten
Alt 08-05-2004, 18:32   #2 (permalink)
Neuer User
 
Registriert seit: Jan 2002
Beiträge: 1.244
hi,

habe es nicht geprüft, aber "else" oder "ELSE" ist ein reserviertes
Wort! Sollte man nicht für ander Zwecke verwenden!

Nur als Tip.
__________________
Mfg aus Brandenburg.

harego

Spiel

Zur Page
harego ist offline   Mit Zitat antworten
Alt 08-05-2004, 23:56   #3 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
danke werde e aendern..
wollte nur wissen ob ich in die richtige richtung hin arbeite
nxfxcom ist offline   Mit Zitat antworten
Alt 09-05-2004, 00:33   #4 (permalink)
meistens harmlos
 
Benutzerbild von rena
 
Registriert seit: Jun 2001
Ort: Stuttgart
Beiträge: 17.643
Re: Perfect As???

Zitat:
Geschrieben von nxfxcom
nach vielem lesen, versuche ich jetzt meine erste seite so zu designen das der GANZE code in einem Keyframe liegt...
Warum?

Will heißen: _den_ perfekten Code gibt es nicht und auch nicht ob in einem Frame oder über die Zeitleiste verteilt, ob nur AS, ob nur Tween oder Kombination, objektorientiert, selbiges in welchem Grad oder auch gar nicht, Komponenten oder nicht, as-Dateien ausgelagert oder nicht, ab MX2004 AS2 oder AS1 ... usw.

Letztlich ist es immer abhängig von der Aufgabenstellung einen möglichst sinnvollen Aufbau zu finden - projektabhängig, auftragsabhängig, etvl teamabhängig, entwicklerabhängig etc. Ein allgemeingültiges Kochrezept wie was ein für alle mal und überall am besten funktioniert gibt es nicht. Das wär ja auch zu einfach.

Gruß
Rena
__________________
www.rena-hermann.de

The angels have the phone box
rena ist offline   Mit Zitat antworten
Alt 09-05-2004, 00:39   #5 (permalink)
brand new user
 
Benutzerbild von RustyCake
 
Registriert seit: May 2002
Ort: Laimbach 6 1/2
Beiträge: 16.884
*rena* zustimm
__________________
Bitte keine Fragen, zu Flash per PM. Dazu ist das Forum da. Danke MFG_RustyCake!
"Wer tanzen will, muß erst gehen lernen"
RustyCake ist offline   Mit Zitat antworten
Alt 09-05-2004, 08:11   #6 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
OK Rena hat da recht,
ich kenne nur so antworten von hilfsbereiten leuten den ich bei einem Problem meine FLA gab,
und die sagten dann:
Das ist mir zuviel wirres zeug,
oder versuche keine tweens zu nutzen..
Zitat:
Du solltest dir angewohnen, alles möglichst ohne Tweens zu machen und alle Scripte - wenn möglich - auf einer Timeline zu halten. Also kein on(EnterFrame) {} mehr usw.!!
will doch auch nur besser werden

Geändert von nxfxcom (09-05-2004 um 08:13 Uhr)
nxfxcom ist offline   Mit Zitat antworten
Alt 09-05-2004, 08:44   #7 (permalink)
...
 
Registriert seit: Oct 2002
Ort: Nürnberg
Beiträge: 3.611
Zitat:
Du solltest dir angewohnen, alles möglichst ohne Tweens zu machen und alle Scripte - wenn möglich - auf einer Timeline zu halten. Also kein on(EnterFrame) {} mehr usw.!!
wer hat den müll geschrieben?
thorben.schmitt ist offline   Mit Zitat antworten
Alt 09-05-2004, 09:14   #8 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
Glaube johanness oder so..


aber haette zu diesem thread andere antworten erwartet z.b.
ist da ein weg wie ich den code haette verkuerzen koenne, oder besser optimieren..
nxfxcom ist offline   Mit Zitat antworten
Alt 09-05-2004, 12:28   #9 (permalink)
helpQLODhelp
 
Benutzerbild von bokel
 
Registriert seit: Feb 2002
Ort: Köln
Beiträge: 8.505
Was mir auffaellt, ist die Benutzung von Instanznamen anstatt this. Das macht den Code wesentlich schwerer zu ändern.

ActionScript:
  1. // schlecht
  2. ABOUT.onLoad = function(){
  3.         ABOUT.gotoAndStop("ABOUT");
  4.         ABOUT.workx = "197.7";
  5.         ABOUT.worky = "225.8";
  6.         ABOUT.workw = "230";
  7.         ABOUT.workh = "270";
  8. }
  9.  
  10. //besser
  11. //in der Methode kann der Instanzname durch this ersetzt werden
  12. ABOUT.onLoad = function(){
  13.         this.gotoAndStop("ABOUT");
  14.         this.workx = "197.7";
  15.         this.worky = "225.8";
  16.         this.workw = "230";
  17.         this.workh = "270";
  18. }
  19.  
  20. // noch besser
  21. //  irgendwo zu Beginn eine Referenz anlegen, und die dann benutzen
  22. aboutReferenz = ABOUT;
  23.  
  24. aboutReferenz.onLoad = function(){
  25.         this.gotoAndStop("ABOUT");
  26.         this.workx = "197.7";
  27.         this.worky = "225.8";
  28.         this.workw = "230";
  29.         this.workh = "270";
  30. }

Mit den Referenzen kannst du einen Clip einfach verschieben oder umbenennen, ohne das du dein Script gross ändern musst.

Ansonsten ist es natürlich Quatsch, keine Tweenings einsetzen zu wollen. Ich nehme immer das, was am schnellsten und einfachsten geht.

mfg .r
bokel ist offline   Mit Zitat antworten
Alt 09-05-2004, 12:31   #10 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
Hey Danke,

super,
ich lerne immer mehr

Danke werde es gleich mal aendern und posten...
nxfxcom ist offline   Mit Zitat antworten
Alt 09-05-2004, 12:45   #11 (permalink)
Blitzuser
 
Registriert seit: Feb 2004
Beiträge: 468
kann ich den GOTO befehl eigentlich auch durch ne referenz erstezen, und dies auch?:
WHO.onRollOut = function() {
WHO.ABOUTMOV.gotoAndStop(1);

hier die v2

ActionScript:
  1. stop();
  2. // SET SPEED
  3. ABOUT.speed = "12";
  4. PRODUCTS.speed = "12";
  5. TEAM.speed = "12";
  6. ELSE.speed = "12";
  7. //SET DISPLACEMENT
  8. aboutgo = "-333";
  9. productsgo = "-333";
  10. teamgo = "933";
  11. elsego = "933";
  12.  
  13.  
  14. //CONTENT BOX
  15. CBOX.onLoad = function() {
  16.     CBOX._visible = false;
  17. };
  18. CBOX.onEnterFrame = function() {
  19. };
  20.  
  21.  
  22. // ABOUT
  23. WHO = ABOUT;
  24. WHO.onLoad = function() {
  25.     this.gotoAndStop("ABOUT");
  26.     this.workx = "197.7";
  27.     this.worky = "225.8";
  28. };
  29. WHO.onEnterFrame = function() {
  30.     WHO._x += (WHO.workx-WHO._x)/WHO.speed;
  31.     WHO._y += (WHO.worky-WHO._y)/WHO.speed;
  32. };
  33. WHO.onRollOver = function() {
  34.     WHO.ABOUTMOV.gotoAndPlay(2);
  35. };
  36. WHO.onRollOut = function() {
  37.     WHO.ABOUTMOV.gotoAndStop(1);
  38. };
  39. WHO.onPress = function() {
  40.     ABOUT.worky = aboutgo;
  41.     PRODUCTS.workx = productsgo;
  42.     TEAM.worky = teamgo;
  43.     ELSE.workx = elsego;
  44. setInterval( opencbox, 2000 );
  45. function opencbox() {
  46.         CBOX._visible = true};
  47. };
  48.  
  49.  
  50. // PRODUCTS
  51. WHO2 = PRODUCTS;
  52. WHO2.onLoad = function() {
  53.     this.gotoAndStop("PRODUCTS");
  54.     this.workx = "381.1";
  55.     this.worky = "173.2";
  56. };
  57. WHO2.onEnterFrame = function() {
  58.     WHO2._x += (WHO2.workx-WHO2._x)/WHO2.speed;
  59.     WHO2._y += (WHO2.worky-WHO2._y)/WHO2.speed;
  60. };
  61. WHO2.onRollOver = function() {
  62.     WHO2.PRODUCTSMOV.gotoAndPlay(2);
  63. };
  64. WHO2.onRollOut = function() {
  65.     WHO2.PRODUCTSMOV.gotoAndStop(1);
  66. };
  67. WHO2.onPress = function() {
  68.     ABOUT.worky = aboutgo;
  69.     PRODUCTS.workx = productsgo;
  70.     TEAM.worky = teamgo;
  71.     ELSE.workx = elsego;
  72. setInterval( opencbox, 2000 );
  73. function opencbox() {
  74.         CBOX._visible = true};
  75. };
  76.  
  77. // TEAM
  78. WHO3 = TEAM;
  79. WHO3.onLoad = function() {
  80.     this.gotoAndStop("TEAM");
  81.     this.workx = "566.5";
  82.     this.worky = "255.6";
  83. };
  84. WHO3.onEnterFrame = function() {
  85.     WHO3._x += (WHO3.workx-WHO3._x)/WHO3.speed;
  86.     WHO3._y += (WHO3.worky-WHO3._y)/WHO3.speed;
  87. };
  88. WHO3.onRollOver = function() {
  89.     WHO3.TEAMMOV.gotoAndPlay(2);
  90. };
  91. WHO3.onRollOut = function() {
  92.     WHO3.TEAMMOV.gotoAndStop(1);
  93. };
  94. WHO3.onPress = function() {
  95.     ABOUT.worky = aboutgo;
  96.     PRODUCTS.workx = productsgo;
  97.     TEAM.worky = teamgo;
  98.     ELSE.workx = elsego;
  99. setInterval( opencbox, 2000 );
  100. function opencbox() {
  101.         CBOX._visible = true};
  102. };
  103.  
  104.  
  105.  
  106. // ELSE
  107. WHO4 = ELSE;
  108. WHO4.onLoad = function() {
  109.     this.gotoAndStop("ELSE");
  110.     this.workx = "293.6";
  111.     this.worky = "396.7";
  112. };
  113. WHO4.onEnterFrame = function() {
  114.     WHO4._x += (WHO4.workx-WHO4._x)/WHO4.speed;
  115.     WHO4._y += (WHO4.worky-WHO4._y)/WHO4.speed;
  116. };
  117. WHO4.onRollOver = function() {
  118.     WHO4.ELSEMOV.gotoAndPlay(2);
  119. };
  120. WHO4.onRollOut = function() {
  121.     WHO4.ELSEMOV.gotoAndStop(1);
  122. };
  123. WHO4.onPress = function() {
  124.     ABOUT.worky = aboutgo;
  125.     PRODUCTS.workx = productsgo;
  126.     TEAM.worky = teamgo;
  127.     ELSE.workx = elsego;
  128. setInterval( opencbox, 2000 );
  129. function opencbox() {
  130.         CBOX._visible = true};
  131. };
  132.  
  133. // MOVS
  134. ABOUT.ABOUTMOV.onLoad = function() {
  135.     ABOUT.ABOUTMOV._visible = true;
  136. };
  137. PRODUCTS.PRODUCTSMOV.onLoad = function() {
  138.     PRODUCTS.PRODUCTSMOV._visible = true;
  139. };
  140. TEAM.TEAMMOV.onLoad = function() {
  141.     TEAM.TEAMMOV._visible = true;
  142. };
  143. ELSE.ELSEMOV.onLoad = function() {
  144.     ELSE.ELSEMOV._visible = true;
  145. };

Geändert von nxfxcom (09-05-2004 um 12:46 Uhr)
nxfxcom 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 00:30 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele