Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 09-01-2006, 19:02   #1 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
Array beschreiben und auslesen: Bitte den Quellcode lesen

Hallo habe Problem beim Array auslesen bekomme immer ein undefined ?????

function regen() {
var max:Number = 100;
var i:Number = 0;
while (i < max) {
zufall = random(75);
attachMovie("tropfen", "tropfen" + i, i);
_root["tropfen" + i]._x = random(700);
_root["tropfen" + i]._y = random(500);
AnfangsPos[i] = _root["tropfen" + i]._x;
//AnfangsPos.push(_root["tropfen" + i]._x);-> funzt auch nicht
trace(AnfangsPos[i]);
_root["tropfen" + i]._xscale = zufall;
_root["tropfen" + i]._yscale = zufall;
_root["tropfen" + i]._rotation = 45;
_root["tropfen" + i]._alpha = random(100);
i++;
}
}
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:05   #2 (permalink)
Pharao a.D.
 
Benutzerbild von Tut-ench-aton
 
Registriert seit: Jul 2004
Ort: 29°58'33.34'' N, 31°07'49.29'' O
Beiträge: 430
irgendwie würde mir da als Flash-Compiler etwas fehlen, sowas wie
Code:
AnfangsPos = new Array()
Tut-ench-aton ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:07   #3 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
hatte ich natürlich gemacht, ich hatte es nur umbenannt .....sry -->
AnfangsPosX
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:12   #4 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
wie muss ich das machen wenn ich zwei positionswerte als objekt speichern und dann auslesen will:

pos = new Array();
function Positions(x,y) {
this.x = x;
this.y = y;
}

...
neu = new Positions(this._x, this._y);
pos.push(neu);

ist das richtig und wenn wie komm ich an den werteinhalt, sprich die zahlen die sich dahinter verbergen ?

auslesenX = pos[i].x;
auslesenY = pos[i].y; ???
muss ich casten??
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:22   #5 (permalink)
pensionist
 
Benutzerbild von troner
 
Registriert seit: Jan 2003
Ort: Thalheim b. Wels
Beiträge: 568
hallo

so ein array musst du mit:

PHP-Code:
var weichArray:Array = new Array();
weichArray = [];
weichArray[0].150;
weichArray[0].150;

//dann erst kannst es auch so abfragen
trace(weichArray[0].x); 
mfg
troner ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:27   #6 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
dh dass das array praktisch ein solches obj selber erzeugt, ich mein das hat dann an jeder indexstelle einen x und einen y wert...was ich meine das spiel könnte ich beliebig weiter spielen

Array[i].x = ...
Array[i].y = ...
Array[i].name = ....
Array[i].farbe = ......etc???
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:31   #7 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
function regen() {
var max:Number = 1000;
var i:Number = 0;
while (i < max) {
zufall = random(75);
attachMovie("tropfen", "tropfen" + i, i);
_root["tropfen" + i]._x = random(700);
_root["tropfen" + i]._y = random(500);
AnfangsPos[i].x = _root["tropfen" + i]._x;
AnfangsPos[i].y = _root["tropfen" + i]._y;
trace(AnfangsPos[i].x);
_root["tropfen" + i]._xscale = zufall;
_root["tropfen" + i]._yscale = zufall;
_root["tropfen" + i]._rotation = 45;
_root["tropfen" + i]._alpha = random(100);
i++;
}
}

funktioniert nicht gibt mir undefined zurück
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:41   #8 (permalink)
pensionist
 
Benutzerbild von troner
 
Registriert seit: Jan 2003
Ort: Thalheim b. Wels
Beiträge: 568
funktioniert nicht weil du ja gar nichts geändert hast!

PHP-Code:
function regen() {
    
AnfangsPos = new Array();
    var 
max:Number 1000;
    var 
i:Number 0;
    while (
i<max) {
        
zufall random(75);
        
attachMovie("tropfen""tropfen"+ii);
        
_root["tropfen"+i]._x random(700);
        
_root["tropfen"+i]._y random(500);
        
//lesen hilft
        
AnfangsPos[i] = [];
        
AnfangsPos[i]._root["tropfen"+i]._x;
        
AnfangsPos[i]._root["tropfen"+i]._y;
        
trace(AnfangsPos[i].x);
        
_root["tropfen"+i]._xscale zufall;
        
_root["tropfen"+i]._yscale zufall;
        
_root["tropfen"+i]._rotation 45;
        
_root["tropfen"+i]._alpha random(100);
        
i++;
    }
}
regen(); 
troner ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:46   #9 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
jo deklariert und initialisiert habe ich das vorher schon global

var AnfangsPos:Array = new Array(1000);

reicht das nicht??
und was bedeutet [] --> initalisierung ohne grösse?
sirobbob ist offline   Mit Zitat antworten
Alt 09-01-2006, 19:47   #10 (permalink)
Neuer User
 
Registriert seit: Sep 2003
Beiträge: 94
ach sry...machst du ein array im array oder was.....muss das nicht mit grösse initialisiert werden?
sirobbob 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 10:28 Uhr.

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


Copyright ©1999 – 2012 Marc Thiele