Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 02-01-2004, 12:48   #1 (permalink)
Neuer User
 
Registriert seit: Sep 2002
Beiträge: 28
optimieren von function()

hallo,

Ich habe Probleme diese folgenden Zeilen in einer Komprimierten Version zu fassen. Irgendwo habe ich immer ein Syntaxproblem...

moveto1 = function(){ posi = position1
pos_final_x= getProperty(_root.posi, _x);
pos_final_y= getProperty(_root.posi, _y);
pos_x = pos_x* 0.6 + ( pos_final_x - this._x)*0.6;
pos_y = pos_y* 0.6 + ( pos_final_y - this._y)*0.6;
this._x += pos_x;
this._y += pos_y;
}

moveto2 = function(){ posi = position2
pos_final_x= getProperty(_root.posi, _x);
pos_final_y= getProperty(_root.posi, _y);
pos_x = pos_x* 0.6 + ( pos_final_x - this._x)*0.6;
pos_y = pos_y* 0.6 + ( pos_final_y - this._y)*0.6;
this._x += pos_x;
this._y += pos_y;
}

moveto3 = function(){ posi = position3
pos_final_x= getProperty(_root.posi, _x);
pos_final_y= getProperty(_root.posi, _y);
pos_x = pos_x* 0.6 + ( pos_final_x - this._x)*0.6;
pos_y = pos_y* 0.6 + ( pos_final_y - this._y)*0.6;
this._x += pos_x;
this._y += pos_y;
}


steuerung über einen Button mit:

on (release) { _root.frame1.onEnterFrame = _root.moveto1;
_root.frame2.onEnterFrame = _root.moveto2;
_root.frame3.onEnterFrame = _root.moveto3;
}

ist viel zu kompliziert..... wie schreibt man eine funktion wie move(posi) {...}?

danke für die Hilfe
patrick
__________________
http://www.twoto.com

Geändert von patate (02-01-2004 um 13:03 Uhr)
patate ist offline   Mit Zitat antworten
Alt 02-01-2004, 13:12   #2 (permalink)
Level up
 
Benutzerbild von Alois
 
Registriert seit: Jun 2001
Ort: Bocholt
Beiträge: 4.155
ActionScript:
  1. moveto = function(posi){
  2. //die ersten beiden Zeilen sind unnötig, ein Hinweis noch dazu:
  3. //getProperty gebraucht kein Mensch mehr
  4. pos_x = pos_x* 0.6 + ( posi._x - this._x)*0.6;
  5. pos_y = pos_y* 0.6 + ( posi._y - this._y)*0.6;
  6. this._x += pos_x;
  7. this._y += pos_y;
  8. }
und auf den Button:
ActionScript:
  1. on (release) {
  2. for(var i=1;i<=3;i++){
  3. _root["frame"+i].onEnterFrame = _root.moveto(_root["position"+i]);
  4. }
  5. }
Gruß

Alois

Edit: sinnvoll wäre noch die oEF's zu entfernen, wenn sie nicht mehr gebraucht werden:
ActionScript:
  1. moveto = function(posi){
  2. if((Math.abs(this._x-posi._x)<0.2)&&(Math.abs(this._y-posi._y)<0.2)){
  3. this._x=posi._x;
  4. this._y=posi._y;
  5. delete(this.onEnterFrame);
  6. }else{
  7. pos_x = pos_x* 0.6 + ( posi._x - this._x)*0.6;
  8. pos_y = pos_y* 0.6 + ( posi._y - this._y)*0.6;
  9. this._x += pos_x;
  10. this._y += pos_y;
  11. }
  12. }
__________________
-Spuckt mir auf den Stuhl, ich will im Grünen sitzen-

Geändert von Alois (02-01-2004 um 13:18 Uhr)
Alois ist offline   Mit Zitat antworten
Alt 02-01-2004, 13:16   #3 (permalink)
Neuer User
 
Registriert seit: Sep 2002
Beiträge: 28
vielen Dank alois für deine Hilfe,
habe leider nicht so viel Ahnung von AS,

patrick
__________________
http://www.twoto.com
patate ist offline   Mit Zitat antworten
Alt 02-01-2004, 13:18   #4 (permalink)
Neuer User
 
Registriert seit: Sep 2002
Beiträge: 28
hatte ein Ähnlichen Skript geschrieben war mir nicht sicher ob es so klappen würde.

Die Datei läuft immer noch nicht aber jetzt weiss ich das es sich um einen anderen Fehler handelt.

grüsse

Patrick
__________________
http://www.twoto.com

Geändert von patate (02-01-2004 um 13:41 Uhr)
patate ist offline   Mit Zitat antworten
Alt 02-01-2004, 14:02   #5 (permalink)
Neuer User
 
Registriert seit: Sep 2002
Beiträge: 28
wenn jemand Zeit hätte und mir sagen könnte wo der fehler ist?

danke patrick
Angehängte Dateien
Dateityp: rar test.rar (2,8 KB, 2x aufgerufen)
__________________
http://www.twoto.com
patate 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:05 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele