Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 20-01-2005, 19:56   #1 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
duplicated mc automatisch bewegen

habe ein bällchen auf bühne, welches sich bewegt;
bei onPress soll dieses dupliziert werden und auch gleich herumzischen;

soweit bin ich derweil(ich habe prb bei i-zuweisung):
ActionScript:
  1. wertx = 20;
  2. werty = 20;
  3. MovieClip.prototype.balls = function() {
  4.     this.onEnterFrame = function() {
  5.         this._x += wertx;
  6.         this._x>=550 ? wertx=-20*Math.random(5) : 0;
  7.         this._x<=0 ? wertx=20*Math.random(8) : 0;
  8.         this._y += werty;
  9.         this._y>=400 ? werty=-20*Math.random(10) : 0;
  10.         this._y<=0 ? werty=20*Math.random(7) : 0;
  11.     };
  12. };
  13. var i = 0;
  14. MC_liner[+i].onPress = function() {
  15.     this.duplicateMovieClip("MC_liner"+i++, i++);
  16. };
  17. MC_liner[+i].balls();
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary

Geändert von andretti (20-01-2005 um 20:20 Uhr)
andretti ist offline   Mit Zitat antworten
Alt 20-01-2005, 20:42   #2 (permalink)
voidboy
 
Benutzerbild von rendner[i]
 
Registriert seit: Sep 2004
Ort: München
Beiträge: 5.588
Code:
MovieClip.prototype.balls = function() { 
    this.onEnterFrame = function() { 
        this._x += wertx;
        if(this._x >= 550) wertx = -20 * Math.random(5);
        else if(this._x <= 0) wertx = 20 * Math.random(8);
        this._y += werty; 
        if(this._y >= 400) werty = -20 * Math.random(10);
        else if(this._y <= 0) werty = 20 * Math.random(7);
    }; 
};
Jetzt nicht falsch verstehen, Deins wahr ja auch nicht falsch...aber Du weist ja!


Und es dürfte reichen wenn Du hier nur einmal das i inkrementierst.
Code:
this.duplicateMovieClip("MC_liner"+i, ++i);
__________________
ERROR: Signature is too large

Geändert von rendner[i] (20-01-2005 um 20:50 Uhr)
rendner[i] ist offline   Mit Zitat antworten
Alt 20-01-2005, 21:01   #3 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
danke;

hast du es getestet?
bei mir funzt des net so right...
ActionScript:
  1. wertx = 20;
  2. werty = 20;
  3. MovieClip.prototype.balls = function() {
  4.     this.onEnterFrame = function() {
  5.         this._x += wertx;
  6.         if (this._x>=550) {
  7.             wertx = -20*Math.random(5);
  8.         } else if (this._x<=0) {
  9.             wertx = 20*Math.random(8);
  10.         }
  11.         this._y += werty;
  12.         if (this._y>=400) {
  13.             werty = -20*Math.random(10);
  14.         } else if (this._y<=0) {
  15.             werty = 20*Math.random(7);
  16.         }
  17.     };
  18. };
  19. var i = 0;
  20. MC_liner.onPress = function() {
  21.     this.duplicateMovieClip("MC_liner"+i, ++i);
  22. };
  23. MC_liner[+i].balls();
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary

Geändert von andretti (20-01-2005 um 21:02 Uhr)
andretti ist offline   Mit Zitat antworten
Alt 20-01-2005, 21:16   #4 (permalink)
voidboy
 
Benutzerbild von rendner[i]
 
Registriert seit: Sep 2004
Ort: München
Beiträge: 5.588
Ich nehme an das untere von Deinem Script funktioniert nicht.

Code:
var i = 0; 
MC_liner.onPress = function() { 
    this.duplicateMovieClip("MC_liner"+i, i); 
}; 
eval("MC_liner"+i++).balls();
Da musst Du natürlich i erst nachdem Du dem mc seine Funktion zugewiesen hast erhöhen .

Mache das immer mit eval, habe das andere auch schon mal gesehen, aber Deine Schreibweise ist da glaub ich falsch.
__________________
ERROR: Signature is too large

Geändert von rendner[i] (20-01-2005 um 21:24 Uhr)
rendner[i] ist offline   Mit Zitat antworten
Alt 20-01-2005, 21:32   #5 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
danke für dein bemühen...

funzt net:
ActionScript:
  1. wertx = 20;
  2. werty = 20;
  3. MovieClip.prototype.balls = function() {
  4.     this.onEnterFrame = function() {
  5.         this._x += wertx;
  6.         this._x>=550 ? wertx=-20*Math.random(5) : 0;
  7.         this._x<=0 ? wertx=20*Math.random(8) : 0;
  8.         this._y += werty;
  9.         this._y>=400 ? werty=-20*Math.random(10) : 0;
  10.         this._y<=0 ? werty=20*Math.random(7) : 0;
  11.     };
  12. };
  13. var i = 0;
  14. MC_liner.balls();//ohne dem aufruf tät der ball gar net moven...
  15. MC_liner.onPress = function() {
  16.     this.duplicateMovieClip("MC_liner"+i, i++);//hier i++ wegen tiefe!!!
  17. };
  18. eval("MC_liner"+i++).balls();
Angehängte Dateien
Dateityp: rar balls_test.rar (4,6 KB, 5x aufgerufen)
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti ist offline   Mit Zitat antworten
Alt 20-01-2005, 22:04   #6 (permalink)
voidboy
 
Benutzerbild von rendner[i]
 
Registriert seit: Sep 2004
Ort: München
Beiträge: 5.588
Dann gib doch Deinem mc ein Exportnamen (in der Bibliothek, Rechtsklick auf Dein mc, dann auf Verknüpfung und bei Bezeichner MC_liner eingeben).
Und lade ihn dynamisch auf die Bühne.

Code:
var i = 1;
_root.attachMovie("MC_liner", "MC_liner", 0)
MC_liner.balls();
MC_liner.onPress = function() {
	_root.attachMovie("MC_liner", "MC_liner"+i, i++).balls();
};
Sorry, aber mit dem duplicated kenn ich mich jetzt auch nicht so aus, das ich Dir sagen könnt woran es liegt.
__________________
ERROR: Signature is too large

Geändert von rendner[i] (20-01-2005 um 22:08 Uhr)
rendner[i] 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 04:38 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele