Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 24-04-2005, 20:23   #1 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
Bots

Hallo,
ich hab grade ein Script von Flashstar runter geladen.
Das ganze sollt so funktionieren:
http://www.2k-town.de/fsbotspol-org.swf

Aber nur die swf, die im zip dabei war funtz!
Wenn ich eine swf-Datei von der fla erzeuge, geht die nicht:
http://www.2k-town.de/fsbotspol.swf

(das Objekt ist zwar vorhanden, steht aber außerhalb des angezeiten Bereichs.

Hier das AS des 1. Bildes:
ActionScript:
  1. if (!init) {
  2.     filmHoehe = 450;
  3.     filmBreite = 600;
  4.     fiehHoehe = 23;
  5.     fiehAbstand = 30;
  6.     step = 5;
  7.     init = true;
  8. }   
  9. function dubliziere (fiehAnzahl) {
  10.     for (i = 1; i <= fiehAnzahl; i++) {
  11.         duplicateMovieClip("Fieh_0", "Fieh_" + i, i);
  12.     }
  13. }       
  14. movieClip.prototype.bewegen = function () {
  15.     if (_name != "Fieh_0") {
  16.         vorMir = "Fieh_" + (mbsubstring(_name, 6, 2) - 1);
  17.         x = _x - _root[vorMir]._x;
  18.            y = _y - _root[vorMir]._y;
  19.         winkel = -(Math.atan2(y, x) / (Math.PI / 180) - 270);
  20.         if (winkel > 360) { winkel = winkel - 360; }
  21.         if (winkel < 0) { winkel = 360 - winkel; }
  22. c = Math.sqrt(x * x + y * y);
  23.         if (c > _root.fiehAbstand) {
  24.             _x += Math.sin(winkel * Math.PI / 180) * _root.step;
  25.             _y += Math.cos(winkel * Math.PI / 180) * _root.step;
  26.         }
  27.         _rotation = -winkel;
  28.     } else {
  29.         Math.random() <= .5 ? winkel -= 10 : winkel += 10;
  30.         neuX = _x + Math.sin(winkel * Math.PI / 180) * _root.step;
  31.         neuY = _Y + Math.cos(winkel * Math.PI / 180) * _root.step;
  32.         if (neuX < _root.fiehHoehe / 2 || neuX > _root.filmBreite - _root.fiehHoehe / 2 || neuY < _root.fiehHoehe / 2 || neuY > _root.filmHoehe - _root.fiehHoehe / 2) {
  33.             winkel += 180;
  34.             neuX = _x;
  35.             neuY = _y;
  36.         }
  37.         if (winkel > 360) { winkel = winkel - 360; }
  38.         if (winkel < 0) { winkel = 360 + winkel; }
  39.         _x = neuX;
  40.         _y = neuY;
  41.         _rotation = -winkel;
  42.     }
  43. }
  44. dubliziere (8);

Was is daran verkehrt??
Die fla gibts als Anlage.

Vielen Dank im voraus für die Hilfe!

greez
special-tag
Angehängte Dateien
Dateityp: zip fsbotspol.zip (3,4 KB, 9x aufgerufen)
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 21:54   #2 (permalink)
~~~~~~~~~~~~
 
Benutzerbild von _geo_
 
Registriert seit: May 2002
Ort: AUSTRIA (OÖ)
Beiträge: 3.298
In flash 5 läufts für MX fehlen die ganzen this usw.

ActionScript:
  1. //mx faehige version
  2.  
  3. stop();
  4.  
  5. if (!init) {
  6.     filmHoehe = 450;
  7.     filmBreite = 600;
  8.     fiehHoehe = 23;
  9.     fiehAbstand = 30;
  10.     step = 5;
  11.     init = true;
  12. }   
  13. function dubliziere (fiehAnzahl) {
  14.     for (i = 1; i <= fiehAnzahl; i++) {
  15.         duplicateMovieClip("Fieh_0", "Fieh_" + i, i);
  16.     }
  17. }       
  18. movieClip.prototype.bewegen = function () {
  19.     if (this._name != "Fieh_0") {
  20.         vorMir = "Fieh_" + (mbsubstring(this._name, 6, 2) - 1);
  21.         x = this._x - _root[vorMir]._x;
  22.            y = this._y - _root[vorMir]._y;
  23.         winkel = -(Math.atan2(y, x) / (Math.PI / 180) - 270);
  24.         if (winkel > 360) { winkel = winkel - 360; }
  25.         if (winkel < 0) { winkel = 360 - winkel; }
  26. c = Math.sqrt(x * x + y * y);
  27.         if (c > _root.fiehAbstand) {
  28.             this._x += Math.sin(winkel * Math.PI / 180) * _root.step;
  29.             this._y += Math.cos(winkel * Math.PI / 180) * _root.step;
  30.         }
  31.         this._rotation = -winkel;
  32.     } else {
  33.         Math.random() <= .5 ? winkel -= 10 : winkel += 10;
  34.         neuX = this._x + Math.sin(winkel * Math.PI / 180) * _root.step;
  35.         neuY = this._Y + Math.cos(winkel * Math.PI / 180) * _root.step;
  36.         if (neuX < _root.fiehHoehe / 2 || neuX > _root.filmBreite - _root.fiehHoehe / 2 || neuY < _root.fiehHoehe / 2 || neuY > _root.filmHoehe - _root.fiehHoehe / 2) {
  37.             winkel += 180;
  38.             neuX = this._x;
  39.             neuY = this._y;
  40.         }
  41.         if (winkel > 360) { winkel = winkel - 360; }
  42.         if (winkel < 0) { winkel = 360 + winkel; }
  43.         this._x = neuX;
  44.         this._y = neuY;
  45.         this._rotation = -winkel;
  46.     }
  47. }
  48. this.dubliziere (8);

mfg geo
__________________
--- :P ---

Blog
Bei unerwünschten Nebenwirkungen zerreißen Sie die Packungsbeilage oder erschlagen ihren Arzt oder Apotheker

Geändert von _geo_ (24-04-2005 um 21:57 Uhr)
_geo_ ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:08   #3 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
Jo, funtz!
Danke!!! *strahl*

Für was sind die "this" eigentlich?

greez
special-tag
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:21   #4 (permalink)
experience++;
 
Benutzerbild von salazar
 
Registriert seit: Jul 2002
Ort: Düsseldorf
Beiträge: 11.347
auszug aus der flash hilfe.... ab und zu reinschauen schadet nicht

Zitat:
Beschreibung

Schlüsselwort; verweist auf ein Objekt oder eine Movieclip-Instanz. Bei der Ausführung eines Skripts verweist this auf die Movieclip-Instanz, die das Skript beinhaltet. Beim Aufruf einer Methode enthält this einen Bezug auf das Objekt mit der aufgerufenen Methode.

In einer an einer Schaltfläche angehängten on-Ereignisprozeduraktion verweist this auf die Zeitleiste mit der Schaltfläche. In einer an einem Movieclip angehängten onClipEvent-Ereignisprozeduraktion verweist this auf die Zeitleiste des Movieclips.
cya, sal
__________________
Bitte keine Flashfragen an mich schicken. Dafür ist ja das Forum da! Das betrifft auch Profilnachrichten.
Chuck Norris hat den Flash Player für alle mobilen Betriebssysteme!
salazar ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:27   #5 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
Question ??

Hmm...

warum machen die enten da so komisches Zeugs?
http://www.2k-town.de/ducksaver2.swf

Warum läuft das nicht so, wie bei http://www.2k-town.de/fsbotspol-org.swf?

Ich kann mir das nicht erklären.
Ich hab
ActionScript:
  1. filmHoehe = 1024;
  2.         filmBreite = 768;
  3.         fiehHoehe = 40;
  4.         fiehAbstand = 80;
  5.         step = 6;
  6.         init = true;
eingestellt.
Mein Film is 1024 x 768 px groß. Das dürfte dann doch passen, oder?
Weiß jemand, für was "fiehHoehe" steht?

thanks
special-tag
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:40   #6 (permalink)
~~~~~~~~~~~~
 
Benutzerbild von _geo_
 
Registriert seit: May 2002
Ort: AUSTRIA (OÖ)
Beiträge: 3.298
In flash 5 konnte man das this einfach weg lassen weil sich flash das fehlende this. einfach dazu 'gedacht' hat, in mx is das aber nicht mehr bzw nur eingeschränkt möglich !

jöh des is wohl mein Fehler, hab beim this einfügen nicht so genau geschaut, da ist wohl irgendwo etwas durcheinander geraten.

ActionScript:
  1. //mx faehige version unbuged
  2.  
  3. stop();
  4.  
  5. if (!init) {
  6.         filmHoehe = 450;
  7.         filmBreite = 600;
  8.         fiehHoehe = 23;
  9.         fiehAbstand = 30;
  10.         step = 5;
  11.         init = true;
  12. }
  13. function dubliziere (fiehAnzahl) {
  14.         for (i = 1; i <= fiehAnzahl; i++) {
  15.                 duplicateMovieClip("Fieh_0", "Fieh_" + i, i);
  16.         }
  17. }
  18. movieClip.prototype.bewegen = function () {
  19.         if (this._name != "Fieh_0") {
  20.                 this.vorMir = "Fieh_" + (mbsubstring(this._name, 6, 2) - 1);
  21.                 this.x = this._x - _root[this.vorMir]._x;
  22.                 this.y = this._y - _root[this.vorMir]._y;
  23.                 this.winkel = -(Math.atan2(this.y, this.x) / (Math.PI / 180) - 270);
  24.                 if (this.winkel > 360) { this.winkel = this.winkel - 360; }
  25.                 if (this.winkel < 0) { this.winkel = 360 - this.winkel; }
  26.                 this.c = Math.sqrt(this.x * this.x + this.y * this.y);
  27.                 if (this.c > _root.fiehAbstand) {
  28.                         this._x += Math.sin(this.winkel * Math.PI / 180) * _root.step;
  29.                         this._y += Math.cos(this.winkel * Math.PI / 180) * _root.step;
  30.                 }
  31.                 this._rotation = -this.winkel;
  32.         } else {
  33.                 Math.random() <= .5 ? this.winkel -= 10 : this.winkel += 10;
  34.                 this.neuX = this._x + Math.sin(this.winkel * Math.PI / 180) * _root.step;
  35.                 this.neuY = this._Y + Math.cos(this.winkel * Math.PI / 180) * _root.step;
  36.                 if (this.neuX < _root.fiehHoehe / 2 || this.neuX > _root.filmBreite - _root.fiehHoehe / 2 || this.neuY < _root.fiehHoehe / 2 || this.neuY > _root.filmHoehe - _root.fiehHoehe / 2) {
  37.                         this.winkel += 180;
  38.                         this.neuX = this._x;
  39.                         this.neuY = this._y;
  40.                 }
  41.                 if (this.winkel > 360) { this.winkel = this.winkel - 360; }
  42.                 if (this.winkel < 0) { this.winkel = 360 + this.winkel; }
  43.                 this._x = this.neuX;
  44.                 this._y = this.neuY;
  45.                 this._rotation = -this.winkel;
  46.         }
  47. }
  48. this.dubliziere (8);

mfg geo
__________________
--- :P ---

Blog
Bei unerwünschten Nebenwirkungen zerreißen Sie die Packungsbeilage oder erschlagen ihren Arzt oder Apotheker

Geändert von _geo_ (24-04-2005 um 22:50 Uhr)
_geo_ ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:52   #7 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
Oje...
wie soll ich den Fehler jetz finden?
Ich kenn mich leider mit AS nicht sooo aus. (Wie sicher nich zu übersehen war )
Und wie finde ich den Fehler am schnellsten? - bzw. woher weiß ich, wo ein "this" hin kommt, und wo nicht? (Ich hab die Beschreibung aus der Flashhilfe nicht so ganz gecheckt.)

mfg
special-tag
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:53   #8 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
Oooooops
Sorry, ich hab voll übersehen, dass du das korrigierte AS mit eingefügt hast.

Danke!!

ciao
special-tag
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:54   #9 (permalink)
~~~~~~~~~~~~
 
Benutzerbild von _geo_
 
Registriert seit: May 2002
Ort: AUSTRIA (OÖ)
Beiträge: 3.298
hab ich auch gerade eben hinzugefügt ;-)
__________________
--- :P ---

Blog
Bei unerwünschten Nebenwirkungen zerreißen Sie die Packungsbeilage oder erschlagen ihren Arzt oder Apotheker
_geo_ ist offline   Mit Zitat antworten
Alt 24-04-2005, 22:58   #10 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
(Nerv ich langsam?)

Ich hab noch ne Frage:
Wie kann ich das machen, dass die 1. Ente nich so ruckartige Bewegungen macht?
Kann man die auch "absoften"?

greez
special-tag
Special-Tag ist offline   Mit Zitat antworten
Alt 24-04-2005, 23:09   #11 (permalink)
~~~~~~~~~~~~
 
Benutzerbild von _geo_
 
Registriert seit: May 2002
Ort: AUSTRIA (OÖ)
Beiträge: 3.298
mal so auf die schnelle: fps hoch und step niedriger machen.
__________________
--- :P ---

Blog
Bei unerwünschten Nebenwirkungen zerreißen Sie die Packungsbeilage oder erschlagen ihren Arzt oder Apotheker
_geo_ ist offline   Mit Zitat antworten
Alt 24-04-2005, 23:20   #12 (permalink)
Neuer User
 
Benutzerbild von Special-Tag
 
Registriert seit: Nov 2003
Beiträge: 143
ok,
und jetz (hoffentlich) die allerletzte frage:
ist es möglich, die enten nicht immer im gleichen abstand laufen zu lassen?
so dass wenn die erste gegen die "wand" läuft und sich erst mal umdrehen muss, die anderen enter sie en bischen "aufstauen", und nich den festen abstand halten und dabei auf der stelle gehn (so wies jatzt der fall is).
siehe hier.

gute nacht
special-tag
Special-Tag 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 21:36 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele