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

i want to change the value of a text and this text is called by another text value..

New Here ,
Feb 18, 2013 Feb 18, 2013

i have a txt_blk1 up to txt_blk32 and i also have a txt_we  .. if the text_we.text has a value of 1 to 32  how can i change the value of txt_block0-32.text to 0.. the text we already generates its own value so i dont have to use for loop.  i've tried to use  _root["txt_blk"+txt_we.text] = 0; im using actionscript 2 .. can someone help me

TOPICS
ActionScript
821
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 ,
Feb 18, 2013 Feb 18, 2013

If txt_blk#'s are also textfields, then you need to assign the 0 to the text property...

_root["txt_blk"+txt_we.text].text = 0;

If they are variables then that line should work.

If it still fails, try tracing the number of characters in the text_we textfield.  If it happens to have more than you expect, it might be defined as a multiline textfield where it needs to be a single line

If that code is on the root timeline I recommend using "this" instead of "_root".  Unnecessary use of _root is best avoided.

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 ,
Feb 18, 2013 Feb 18, 2013

the textfield wont still change to zero.. but thank you sir it means a lot.. the txt_blk1-32 change its value when a hittest run on a mc_chip ive made. i have 24 chips and if the chip somehow collide with the block then it will change depending on what chip is moved but doesnt change the value to 0 when it leaves a block .. im making a board game similar to checkers. just sharing what i'm going through right now.. again sir thank you

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 ,
Feb 18, 2013 Feb 18, 2013

You should show the code that is related to the problem you are haviing.  It does not appear trhe one line of code is where the problem lies.  I see you started another posting, so if you are pursuing this further in that posting I will stop trying to help here.

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 ,
Feb 18, 2013 Feb 18, 2013

i'm sorry sir.. its just that im on a hurry and i need all the help that i can get for my thesis.. so while i havent figure out what to do for this problem.. i have to move to another problem just to save time. and another thing is i don't really know where did i go wrong..

this is the code i've put inside the chips

on (press) {

                    blocknum=32;

          for(i=1;i<=blocknum;i++){

                    _

                    if (this.hitTest(_root["block"+i])) {

                                        this._x=_root["block"+i]._x;

                                        this._y=_root["block"+i]._y;

                                        trace("Source "+i)

                                        _root.txt_recent.text = i;

                                        break;

                              }

                              /*if (this._x==_root["block"+i]._x and this._y==_root["block"+i]._y) {

                                        _root.txt_recent.text = i;

                                        trace("block "+i);

                                        break;

                                        }*/

          }

          startDrag(this);

 

          //tempx=this._x;

          //tempy=this._y;

}

on (release) {

 

          blocknum=32;

          for(i=1;i<=blocknum;i++){

                              if (this.hitTest(_root["block"+i])) {

                                        trace("des1:"+parseInt(_root.txt_recent.text)+3 );

                                        trace("des2:"+parseInt(_root.txt_recent.text)+4 );

                                        trace("des3:"+parseInt(_root.txt_recent.text)+5 );

                                        trace("des4:"+parseInt(_root.txt_recent.text)-3 );

                                        trace("des5:"+parseInt(_root.txt_recent.text)-4 );

                                        trace("des6:"+parseInt(_root.txt_recent.text)-5 );

                                        if(i==parseInt(_root.txt_recent.text)+3 or i==parseInt(_root.txt_recent.text)+4 or

                                           i==parseInt(_root.txt_recent.text)+5 or i==parseInt(_root.txt_recent.text)-3 or

                                           i==parseInt(_root.txt_recent.text)-4 or i==parseInt(_root.txt_recent.text)-5) {

                                                  this._x=_root["block"+i]._x;

                                                  this._y=_root["block"+i]._y;

                                                  _root.txt_we.text = _root.txt_recent.text;

                                                  _root["txt_blk"+txt_we.text].text = 0;

                                                  _root.txt_recent.text = i;

                                                  break;

                                        }

                                        else{

                                                  this._x=_root["block"+_root.txt_recent.text]._x;

                                                  this._y=_root["block"+_root.txt_recent.text]._y;

 

                                                  break;

                                        }

and this is the code i putted on the block13

all block have corresponding txt_blk according to its number:

onClipEvent(enterFrame) {

                    chipnum=24;

                    for(i=1;i<=chipnum;i++){

        if (this.hitTest((_root["chip"+i]))) {

                              _root.txt_blk13.text = i;

                    }

                    }

}

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 ,
Feb 19, 2013 Feb 19, 2013

The first thing you should do is trace the string you are creating to make sure it is creating what you think it should be...

       trace("txt_blk"+txt_we.text);

If you need to use _root to target the other objects, then you probably need to use it to target txt_we as well.

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 ,
Feb 25, 2013 Feb 25, 2013

so if i trace and it inputted a NaN then there's something wrong in my code ?

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 ,
Feb 26, 2013 Feb 26, 2013
LATEST

Yes, I would have to conclude that somewhere there is a problem with your code if you are not seeing the data you expect to see in the trace. 

If you are saying that the txt_we.text portion is tracing "NaN" in that trace, then I have to conclude that the txt_we textfield is displaying "NaN" as well since there is nothing in the trace that is trying to coerce the text property to be a number.

Focus on running down what defines the text_we text.  USe the trace function to hunt down where the problem originates

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