Error #1006: textBoxSet is not a function
Here is a little background about this error and myself:
I have been trying to fix this for some 2 hours, not qutie sure how to or what to fix. I am a Java programmer and the tutor in my school and switched to this language because it was "easier" to have GUI, animation, and interaction. As such, I am still stumbling around actionscript a bit.
As or right now, this code is intended to 1) set up a red rectangle movieClip, 2) move it 200 pixels and 3) have it call a function "textBoxSet" from the VeggieDisplay class which is imported and supposedly working.
1 and 2 work just fine, as they are relatively easy steps. However, when I try running displayItem.textBoxSet(); I recieve:
TypeError: Error #1006: textBoxSet is not a function.
at ProduceProject_fla::MainTimeline/frame1()
I am not quite sure why this happens. I have everything set up and it should work. The methods arent nested etc. etc. and such.
For now, this is all I have to ask. I am going to worry about the other thing that isn't working later (class item is undefined in timeline when shouldnt be etc.)
Code in the Timeline at Frame 1:
import packages.VegetableDisplay;
var displayItem:VegetableDisplay = new VegetableDisplay();
trace(displayItem);
displayItem.x = 200;
this.addChild(displayItem);
displayItem.textBoxSet();
Code for VegetableDisplay:
package packages{
import flash.display.MovieClip;
import packages.Vegetable;
import flash.text.TextField;
public class VegetableDisplay extends MovieClip {
public var veggieItem:Vegetable;
//two text boxes present in the movieclip
var nameText:TextField = new TextField();
var typeText:TextField = new TextField();
//"constructor". Not constructing much
public function VegetableDisplay() {
// constructor code
trace("9");
veggieItem = new Vegetable();
trace("veggieItem " + veggieItem.getName());
}
//set text boxes present in the movieClip
private function textBoxSet():void{
trace("in");
nameText.text = veggieItem.getName();
typeText.text = veggieItem.getType();
}
}
}
Vegetable Class:
package packages {
public class Vegetable {
/*I actually do have an issue with this class as well. When values are called form it, they come as "undefined" rather than what they should be.
Why and how could I fix it*/
private var myName:String = new String(); //name of item
private var typeNum:Number = 0; //0: vegetable 1: fruit
private var myType:String = new String(); //string associated
private var classNum:Number = 0; //stone fruits and such
private var itemClass:String = new String(); //string associated
private var growingSeason:Array; //months
private var growingArea:Array; //areas
public function Vegetable() {
// constructor code
myName = "tomato"; //temporary until begin importing rather than static.
myType = "fruit";
}
//Get methods
public function getName():String{
return myName;
}
public function getTypeNum():Number{
return typeNum;
}
public function getType():String{
return myType;
}
public function getClassNum():Number{
return classNum;
}
public function getItemClass():String{
return itemClass;
}
public function getGrowingSeason():Array{
return growingSeason;
}
public function getGrowingArea():Array{
return growingArea;
}
//Set methods
public function setName(mName){
myName = mName;
}
public function setTypeNum(tyNum){
typeNum = tyNum;
}
public function setMyType(mType){
myType = mType;
}
public function setClassNum(claNum){
classNum = claNum;
}
public function setItemClass(itClass){
itemClass = itClass;
}
public function setGrowingSeason(growSeason){
growingSeason = growSeason;
}
public function setGrowingArea(growArea){
growingArea = growArea;
}
}
}
Any and all help would be greatly appreciated. Thank you.
Added Vegetable class if anyone bothers to build the class and test. The make-up of the textbox is just a rectangle with two text boxes "nameText" and "typeText" so far, set to Dynamic text and such.
Also realized I never finished with the name of the question, so I made it less ambiguous.