I have been having trouble with AS3, most specifically with the "TypeError: Error #1006: value is not a function" error message. I'm an absolute beginner, but I've checked out the other stackOverflow questions related to Error #1006, and on other sites, and have been unable to find the source of my problem.
The Error appears when I try and call the newQueen function.
function newQueen(queenType):void
{
switch (queenType)
{
case 1 :
guardianLoyalty = 0;
break;
case 2 :
gathererLoyalty = 0;
break;
case 3 :
acolyteLoyalty = 0;
break;
case 4 :
vesselLoyalty = 0;
break;
default :
break;
}
queenRndTrait1 = randRange(1,queenTraitArray.length);
queenRndTrait2 = randRange(1,queenTraitArray.length);
queenTraitArray[queenRndTrait1](queenType,1);
queenTraitArray[queenRndTrait2](queenType,2);
queenRndDescription = randRange(1,queenDescriptionArray.length);
queenDescriptionArray[queenRndDescription](queenType);
queenRndName = randRange(1,queenNameArray.length);
queenNameArray[queenRndName](queenType);
}
Please tell me if there is anything else I can include to make answering this question easier : )
Edit:
var queenDescriptionArray:Array = new Array(queenDescription1);
function queenDescription1(queenType):void
{
switch (queenType)
{
case 1 :
guardianQueenDescription = "Dummy Description One";
break;
case 2 :
gathererQueenDescription = "Dummy Description One";
break;
case 3 :
acolyteQueenDescription = "Dummy Description One";
break;
case 4 :
vesselQueenDescription = "Dummy Description One";
break;
default :
break;
}
}
I was calling the function like newQueen(1);
Edit 2, Solved:
Thanks, null!
I had solved this problem before it arose in other parts of my program, I couldn't figure out what was different about this function!(Since I'm new, I try not to copy and paste, even my own code)
The solution was to add a "-1" to the end of the randomization lines, like so:
queenRndTrait1 = randRange(1,queenTraitArray.length)-1;