开发者

how to write on screen in AS3

So I am creating a module开发者_高级运维 and I have a screen that I need to be able to allow the users to write questions that they have on their screens in a text box. Does anyone know how to do this?

This is the basic setup that I use for every screen:

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


For users to input text, simply create a textfield and set its "type" property to TextFieldType.INPUT. When you go to retrieve this data, just access the textFields "text" prop.

  • Update -

Ok = simple google search on "AS3 textField tutorial", first hit was this tutorial, which I yanked and added a couple things to for you. Its fairly basic and well documented, so, depending on your level of experience, should prove illuminating.

//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);

Hope that helps!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜