将textfield中的值赋给变量

时间:2014-01-20 05:48:52

标签: actionscript-3

如何从变量中的textfield传输值?

[CODE]

import flash.text.*;
import flash.events.*;
import flash.display.*;

//Button named Player_save
Player_save.addEventListener(MouseEvent.CLICK, savename);

function savename(event:MouseEvent):void
{
    playerlist.text=player_name.text;
    trace(player_name.text);
    //player_name.text is the textfield 
}

[/ CODE]

3 个答案:

答案 0 :(得分:0)

简单如下:

var myVariable:String = player_name.text;

答案 1 :(得分:0)

首先声明变量,然后将文本字段中的文本值分配给它。

var playerName:String = player_name.text;

答案 2 :(得分:0)

试试这个: var _pName = player_name.text;