thanks for your reply cor, you are correct, p1 is a parameter for the
constructor (as string) and for the method (as array).
Still, if i change the datatype of data to string the error persists
public function setGabarito(p1:Array) {
var tamanho = p1.length - 1 // o indice comeca com zero entao tem 1
elemento a menos.
var data:String;
//copia os membros do array
for (var r = 0; r <= tamanho; r++ ) {
data = p1[r];
//data = "hello";
aRespGabarito[r] = data; <-any of the declarations above for data
results in an error.
}
}
----- Original Message -----
From: "Cor" <c...@chello.nl>
To: "'Rodrigo Augusto Guerra'" <rodr...@alumni.org.br>; "'Flash Coders
List'" <flashcoders@chattyfig.figleaf.com>
Sent: Thursday, July 01, 2010 10:42 AM
Subject: RE: [Flashcoders] passing an array as a method = TypeError: Error
#1009: Cannot access a property or method of a null object reference.
Data is an Array and p is a String
-----Original Message-----
From: flashcoders-boun...@chattyfig.figleaf.com
[mailto:flashcoders-boun...@chattyfig.figleaf.com] On Behalf Of Rodrigo
Augusto Guerra
Sent: donderdag 1 juli 2010 15:36
To: Flash Coders List
Subject: [Flashcoders] passing an array as a method = TypeError: Error
#1009: Cannot access a property or method of a null object reference.
Hi all,
I'm creating a simple class that has an method that will receive an array
as
a parameter and store it inside the class in a property. This gives me the
error below and I'm stuck. Also I would like to know why if I change the
code inside the method setGabarito to just ( aRespGabarito = p1 ) it
works...
TypeError: Error #1009: Cannot access a property or method of a null
object
reference.
at trueFalse/setGabarito()
at tf_teste_fla::MainTimeline/frame1()
this is the class:
package {
import flash.display.Sprite;
public class trueFalse extends Sprite{
//propriedades
var nome:String;
var aRespGabarito:Array; //tera o gabarito do exercicio
//construtor
public function trueFalse(p1:String) {
nome = p1;
}
public function setGabarito(p1:Array) {
var tamanho = p1.length - 1 // o indice comeca com zero entao tem 1
elemento a menos.
for (var r = 0; r <= tamanho; r++ ) {
var data:Array = p1[r];
aRespGabarito[0] = data; <<-- ERROR HERE
trace(aRespGabarito[0]);
}
}
}
}
and this is the code inside the test movie:
var usuario:trueFalse = new trueFalse("aa");
var arrQuestao:Array = new Array();
arrQuestao[0] = ["btV1","btX1","btV1",0];
arrQuestao[1] = ["btV2","btX2","btX2",0];
arrQuestao[2] = ["btV3","btX3","btX3",0];
usuario.setGabarito(arrQuestao);
thanks for any help,
rodrigo.
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Geen virus gevonden in het binnenkomende-bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 9.0.830 / Virusdatabase: 271.1.1/2974 - datum van uitgifte:
06/30/10
20:38:00
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders