PDA

View Full Version : Need SERIOUS HELP with a class...


ghettoo
09-16-2004, 03:40 PM
Ok people I am new to classes and I am try to build a little one, its very simple. But I have built it and there seems to be some sort of error, I can not find any error within the class but still it comes up with the same message. I have tried to debug forever now and I woulod be clad if one of you actionscriptors could help me.

--------------------------------------------

THE CLASS SCRIPT
This should get a variable from fla store it into an array, then when the getters are called in the fla, it should send back a string which is picked out from the array according to what position the fla sent.



class CommandHistory {

//Variables
private var _sCommand:String;
private var _nCommandLine:Number;
private var _aHistory:Array;

//Getters and Setters
public function set addCommand(sUserInput:String):Void {
_aHistory.push(sUserInput);
}

public function set addLine(nLine:Number):Void {
_nCommandLine = nLine;
}

public function get LastCommand():String {
return _aHistory[_nCommandLine];
}

//Class Constructor
function CommandHistory() {
_aHistory = new Array();
}

}




THE FLA SCRIPT
This will send information about the line number, and the string that is wished to store to store in the array to the class.



var chCommand:CommandHistory = new CommandHistory();
var sCommand:String = new String("Command");
var nLine:Number = 0;
chCommand.addCommand = sCommand;
chCommand.addLine = nLine;
trace(chCommand.LastCommand);




THE ERROR MESSAGE



**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 5: There is no property with the name 'addLine'.
chCommand.addLine = nLine;

Total ActionScript Errors: 1 Reported Errors: 1




--------------------------------------------

Can any of you scriptors understand why this error is happening, or how to fix this. i would be much greatful. :D :D :D :D :D :D

thanx
ghettoo.

madgett
09-16-2004, 03:44 PM
I see addLine...don't make it a setter method, and see if it works.

deadbeat
09-16-2004, 05:34 PM
Beats me...I copied and pasted your exact code into a new class & FLA file, and ran it without getting any errors...

K.

senocular
09-16-2004, 05:41 PM
try clearing your aso folder

Xeef
09-16-2004, 05:59 PM
hi

also trie it work fine!!

check your actionscript 2.0 setings

similayr hapens to me when i worked whit diferent wersions and diferent folders
actionscript 2.0 setings look in the order of setings
mean

folder oldAS /CommandHistory /notworking why ever
folder newAS /CommandHistory /working
flash will use the one first in the setings!! = not working

ghettoo
09-16-2004, 09:16 PM
Ok thanks guys... I will try updatimg my version... althou i am using flash mx 2004 7.2.

thanks for all you replys :D :D :D :D :D :D
ghettoo