Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Function not returning the right value

New Here ,
Aug 05, 2013 Aug 05, 2013

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

TOPICS
ActionScript
625
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Aug 06, 2013 Aug 06, 2013

Start the investigation by using the trace() function to see what value is being passed to and returned by whatever _languageClass.getTranslation() is.

Translate
LEGEND ,
Aug 06, 2013 Aug 06, 2013

Start the investigation by using the trace() function to see what value is being passed to and returned by whatever _languageClass.getTranslation() is.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 06, 2013 Aug 06, 2013

Ok, I figured it out, it was not returning the correct value from the _languageClass.getTransation(). I had to fix the _languageClass. Thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 06, 2013 Aug 06, 2013
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines