2011-05-16 33 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