如何在AS3的屏幕上书写

时间:2011-05-16 19:13:13

标签: actionscript-3 textbox

所以我正在创建一个模块,我有一个屏幕,我需要能够让用户在文本框中的屏幕上写下他们的问题。有谁知道怎么做?

这是我用于每个屏幕的基本设置:

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");
       }
    }
}

1 个答案:

答案 0 :(得分:2)

要让用户输入文字,只需创建一个文本字段并将其“type”属性设置为TextFieldType.INPUT即可。当您去检索此数据时,只需访问textFields“text”prop。

  • 更新 -

Ok =简单的谷歌搜索“AS3 textField教程”,第一次点击是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);

希望有所帮助!