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.
--------------------------------------------
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.