hello. i've an array and in a function and i don't know how to get it out of the funktion because i want to use it in a dynamic way. ?return? does not work. i try it last night for 3 hours and i find no way. please help me an sorry for my teribble english, i'm a german one. bernhard
you can return an array from a function: function a1(x):Array{ var a:Array; for(var i=0;i<x;i++){ a.push(i+1); } return a; }
yes, that is what i tryed. i get a return in the compiler, he says the thing giving back is not allowed to be defined. (whit an 1051-number. my compiler talks german to me.)
my error. use: function a1(x):Array{ var a:Array = []; for(var i=0;i<x;i++){ a.push(i+1); } return a; }
it is not working. my code look a little different, because it's an ?LotOfDimension? - array. here is the part of my code for filling it. var arrayFromXML:Array = []; // variabel zum identifizieren der oberen dimension des arrays var rein:uint = 0; for each (var knoten in myXML.hallo) { arrayFromXML[rein]= [(knoten.titel), (knoten.nummer), (knoten.titel)]; rein = rein + 1; } return arrayFromXML; and, thank you for your talking with me.
so i've do that. in one way it's great, because in my dynamic work now the xml is not loadet again and again. in the other way - the compiler is still telling me the same word's like befor. maybe there is something more wrong in my code. here he is: function xmlLoaded(event:Event):void { myXML = XML(myLoader.data); } function namen(event:MouseEvent):void { // ERSTELLEN EINES MEHRDEMINSIONALEN ARRAYS, INDEM DIE XML-DATEN EINGELESEN WERDEN var arrayFromXML:Array = []; // variabel zum identifizieren der oberen dimension des arrays var rein:uint = 0; for each (var knoten in myXML.hallo) { arrayFromXML[rein]= [(knoten.number), (knoten.nummer), (knoten.titel)]; // der erste eintrag ist nur f?r die sortierung! rein = rein + 1; } trace(arrayFromXML[1][1]); return arrayFromXML; ... ... ...
hm. changing this, the cmpiler tell me that at the end of the function nothing is giving back. so, my battery is empty and it a chance for me to get home and read again in the documention antil my eyes stop working. anyway, thank you for your words.
Don't see what you're looking for? Try a search.
|