2012-10-04 112 views

回答

1

嘗試更換:

var cityName:String = "Dallas,TX"; 
cityName.replace(",",", "); 
trace(cityName); 
0
package { 
    public class Main extends Sprite {  
     private var _txt:TextField; 
     public function Main() { 
      // constructor code 
      _txt = new TextField(); 
      _txt.type = TextFieldType.INPUT; 
      _txt.border = true; 
      addChild(_txt);    
      _txt.addEventListener(TextEvent.TEXT_INPUT,onTextChange); 
     } 
     //onTextChange function will fire in every key press except for the Delete or Backspace keys. 
     private function onTextChange(e:TextEvent):void{ 
      if(_txt.text.charAt(_txt.text.length-1) == ","){ 
         //Appends the string specified by the _txt parameter to the end of the text field. 
         _txt.appendText(" "); 
         //setSelection - I have used for move the text cursor to end of the textField. 
          _txt.setSelection(_txt.length,_txt.length); 
         } 
        } 
       } 


     } 
0

這是一個兩年前的帖子,但這是未來遊客的答案。

使用帶空格的引號並使用字符之間的加號。

例如:

trace("Dallas," + " " + "TX"); 

this.location_text_field.text = String("Dallas," + " TX"); 

在第一個例子有在中間 兩個引號之間的空間在第二示例中的空間是達拉斯後,和TX之前

相關問題