以另一种方法访问MovieClip

时间:2012-02-22 08:12:22

标签: flash actionscript

var PlayerScore:TextField = new TextField();  

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


var myFormat:TextFormat = new TextFormat();
myFormat.size = 30;

PlayerScore.defaultTextFormat = myFormat;

PlayerScore.text = _player_score.toString();
PlayerScore.width = 250;  
PlayerScore.x = 70;  
PlayerScore.y = -20;
PlayerScore.textColor = 0xFFFFFF;

我在构造函数中使用它

我该如何使用

PlayerScore.text = _player_score.toString();

另一种方法?

1 个答案:

答案 0 :(得分:0)

使用此方法{         PlayerScore.text = _player_score.toString();

分配变量:example

    var cash:int = 500;  // cash is the variable//

    showTextBTN.addEventListener(MouseEvent.CLICK, variableTotext);

    function variableTotext(){
    Money.text = cash.toString();// the variable cash will output in Money text box
    }

在舞台上添加一个按钮或mc,给它一个实例名称“showTextBTN”。 然后添加一个实例名称为“Money”的动态文本框。 在动作时间轴(as3)中添加上述代码; 编译/运行电影