Copy link to clipboard
Copied
Hi, I'm having a strange problem and am hoping someone knows how to fix it....
I'm trying to send a string to a function in another class and have it return it in a textfield, so I can add it to a movieclip and to the stage. I am using it for several buttons.The problem is when I put a string value in it returns a string value for the previous call to the function which is not the string value I want to use. Here's the function:
public function replaceMCTxt( mcString:String, xPos:Number,
yPos:Number, Width:uint, Height:uint, newFontSize:uint, rolloverText:Boolean = false):TextField {
var newMCTxt:TextField = new TextField();
newMCTxt.x = xPos;
newMCTxt.y = yPos;
newMCTxt.width = Width;
newMCTxt.height = Height;
var textFormat:TextFormat = new TextFormat();
textFormat.align = _gameModel.screenFontAlign;
textFormat.size = newFontSize;
textFormat.font = _gameModel.screenFont;
textFormat.color = _gameModel.screenFontColor;
newMCTxt.defaultTextFormat=textFormat;
newMCTxt.text = _languageClass.getTranslation(mcString);
newMCTxt.selectable = false;
return newMCTxt;
}
i'm trying to call it with this statement in another class:
_moreGamesTxtField = _updateLanguageClass.
replaceMCTxt("MORE GAMES", _gameModel.moreGamesTxtXPos,
_gameModel.moreGamesTxtYPos, _gameModel.moreGamesTxtWidth,
_gameModel.moreGamesTxtHeight, _gameModel.moreGamesTxtFontSize);
Instead of giving me a "MORE GAMES" movieclip it gives me a "PLAY" movieclip which is what the previous call to the function used. I also had a similar problem in another function where it was doing the same thing with filtering different buttons, so I think the problem is in the function ,but I'm not a good enough programmer to know what it is. If anyone has an idea please let me know. Thank you.....
Start the investigation by using the trace() function to see what value is being passed to and returned by whatever _languageClass.getTranslation() is.
Copy link to clipboard
Copied
Start the investigation by using the trace() function to see what value is being passed to and returned by whatever _languageClass.getTranslation() is.
Copy link to clipboard
Copied
Ok, I figured it out, it was not returning the correct value from the _languageClass.getTransation(). I had to fix the _languageClass. Thanks
Copy link to clipboard
Copied
You're welcome
Find more inspiration, events, and resources on the new Adobe Community
Explore Now