hopefully someone can help me out here… I’m having trouble calling a variable in a custom Class. I have the variable defined as a Number and calling it as a parameter in the main class function. when i trace it from the main function is returns the correct value, but when i call it again from another function, it returns undefined… the weird thing is that i have another parameter from that same function being called outside of the main class function and that on works! wth
the imageNumber var is the problem.
here’s the script:
class MenuButton extends MovieClip
{
var target : MovieClip;
var target2 : MovieClip;
var btnText : String;
var imageNumber : Number;
var textLabel : MovieClip;
var btnName : TextField;
var imgLoader : MovieClip;
var txtString : String;
//
function MenuButton (target, target2, btnText, imageNumber)
{
this.target = target;
this.target2 = target2;
this.btnText = btnText;
this.imageNumber = imageNumber;
this.target.textLabel.btnName.text = this.btnText;
trace ("btnText: " + this.btnText);
this.onRollOver = this.over;
this.onRollOut = this.out;
this.onRelease = this.release;
this.txtString = "headerImg/img" + this.imageNumber + ".jpg";
//trace ("imageNumber: " + this.imageNumber);
//trace ("imgURL: " + this.txtString);
}
function over ()
{
this.gotoAndStop ("over");
this.target2.createEmptyMovieClip ("imgHolder");
this._parent._parent.imgLoader.loadMovie (this.txtString);
trace ("imageNumber: " + this.imageNumber);
trace ("imgURL: " + this.txtString);
}
function out()
{
this.gotoAndStop ("start")
}
function release()
{
this.getURL ("http://URL/" + this._name + ".html");
}
}
just as an added measure, i tried coding the txtString var as just a straight line of text(without adding the this.imageNumber result) and when i call it in the “over” function, it works. but for some reason as soon as i add the imageNumber var into the equation it will both vars (txtString and imageNumber) return “undefined”
any help would be greatly appreciated… thanks