2011-05-16 77 views
1

因此,我正在創建一個模塊,並且我有一個屏幕,我需要允許用戶在文本框中寫入屏幕上的問題。有誰知道如何做到這一點?如何在AS3的屏幕上書寫

這是我使用的每一個畫面的基本設置:

package screens 
{ 

import flash.filters.*; 
import flash.text.*; 
import mapSystem.screenSystem.*; 
import mapSystem.*; 
import screens.*; 
import caurina.transitions.Tweener; 



public class screen4 extends screenBase 
{ 


     public function screen4(pSystem:mapManager) 
     { 
      super(pSystem); 
      numActions = 1; 

     } 



    public override function onAction() 
     { 
      if (actionStep == 1) 
      { 
        map.fID("54"); 
      } 
     } 


     public override function onEnter() 
     { 
      map.zoomTo("full"); 
     } 
    } 
} 

回答

2

對於用戶輸入文字,只需創建一個文本框和它的「類型」屬性設置爲TextFieldType.INPUT。當你去檢索這些數據時,只需訪問textFields「text」道具。

  • 更新 -

OK =簡單的谷歌的「AS3文本框教程」搜索,第一擊是this tutorial,我猛拉,並添加了幾件事情要你。它相當基礎且有據可查,因此,取決於你的經驗水平,應該證明這一點。

//Creating the textfield object and naming it "myTextField" 
var myTextField:TextField = new TextField(); 

//Here we add the new textfield instance to the stage with addchild() 
addChild(myTextField); 

//Here we define some properties for our text field, starting with giving it some text to contain. 
//A width, x and y coordinates. 
myTextField.text = "input text here"; 
myTextField.width = 250; 
myTextField.x = 25; 
myTextField.y = 25; 


//@b99 addition 
myTextField.type = TextFieldType.INPUT; 


//This is the section for our text styling, first we create a TextFormat instance naming it myFormat 
var myFormat:TextFormat = new TextFormat(); 

//Giving the format a hex decimal color code 
myFormat.color = 0xAA0000; 

//Adding some bigger text size 
myFormat.size = 24; 

//Last text style is to make it italic. 
myFormat.italic = true; 

//Now the most important thing for the textformat, we need to add it to the myTextField with setTextFormat. 
myTextField.setTextFormat(myFormat); 

希望有所幫助!

+0

對不起,仍然是一種新的,我得到你在說什麼,但困惑,究竟從哪裏開始我猜 – kirsten 2011-05-16 19:58:47

+0

沒關係,我想通了,它的工程很棒!非常感謝你的幫助! – kirsten 2011-05-16 20:16:04

+0

聽起來不錯。很高興你能解決問題。你仍然可以看看我的更新......乾杯! – Bosworth99 2011-05-16 20:18:55