all groups > flash actionscript > october 2006 >
You're in the

flash actionscript

group:

plus (+) and minus (-)


Re: plus (+) and minus (-) SMB
10/22/2006 1:08:47 PM
flash actionscript:

[quoted text, click to view]

namn is a String. Strings can be concatenated with a + because it makes
sense.
But subtracting it could mean many things like removing matches from the end
of the String, or removing all matches.

Instead there are other ways to do this, for instance...

field.text = field._name.split("_txt")[0];

plus (+) and minus (-) thejokerman05
10/22/2006 7:17:25 PM
This works;
var namn = field._name;
field.text = (namn +"_txt");

This doesn't;
var namn = field._name;
field.text = (namn -"_txt");

How to leave out "_txt" from name? I could rename my instance but just want to
know why this doesn't work.
Re: plus (+) and minus (-) NSurveyor
10/22/2006 8:35:53 PM
The way you are using + is not addition, but rather concatenation. The - is
only for subtraction, there is no string "subtraction". However, you can take a
substring or split your string on _txt and take the first element:

var namn = field._name;
field.text = namn.substr(0,-4);//take all but the last 4 characters

var namn = field._name;
field.text = namn.split('_txt')[ 0 ] // take everything before the first _txt
encounter
Re: plus (+) and minus (-) thejokerman05
10/22/2006 8:43:33 PM
AddThis Social Bookmark Button