as3将一个文本字段的内容分配给另一个

时间:2014-01-01 18:36:20

标签: actionscript-3 flash var

我想要传递

的内容
  

B1L_bnt.text

  

buddy_txt.text

谁能告诉我黄在这做什么?

function clickHandler(event:MouseEvent):void
    {
        /*container_mcM.removeEventListener(MouseEvent.CLICK,clickHandler);*/
        var clickedObject:DisplayObject = event.target as DisplayObject;
        var bobby = Object(root).littlepicker.B1L_bnt.text;

        if (clickedObject.name == 'frd_bnt1')
        {
            Object(root).BFFwho.buddy_txt.text = "bobby";
            Object(root).gotoAndPlay(15);

        }

1 个答案:

答案 0 :(得分:2)

试试这个:

function clickHandler(event:MouseEvent):void
    {
        /*container_mcM.removeEventListener(MouseEvent.CLICK,clickHandler);*/
        var clickedObject:DisplayObject = event.target as DisplayObject;
        var bobby = Object(root).littlepicker.B1L_bnt.text;

        if (clickedObject.name == 'frd_bnt1')
        {
            Object(root).BFFwho.buddy_txt.text = bobby;
            Object(root).gotoAndPlay(15);

        }

问题在于您声明了一个名为bobby的变量。当您尝试设置buddy_txt的文本时,您将其设置为文字String' bobby'而不是变量的值。