AS3 - Trace - Click button

吃可爱长大的小学妹 提交于 2019-12-08 06:35:43

问题


I am trying to click on a button and trace out a number "1" onto the stage/same scene.

I have this code:

 button1.addEventListener(MouseEvent.CLICK, myClickReaction1);
 function myClickReaction1 (e:MouseEvent):void{
 trace("1");
 }

BUT it traces onto the output of flash and not onto the scene.

please help

thanks


回答1:


trace("1"); will go to the output panel it is intended for debugging.

If you want to see something on the stage, you will need to create a TextField and set it's text property to whatever you want.

button1.addEventListener(MouseEvent.CLICK, myClickReaction1);

function myClickReaction1 (e:MouseEvent):void{
    var tf:TextField = new TextField();
    tf.text = "1";
    addChild(tf);
}


来源:https://stackoverflow.com/questions/15885703/as3-trace-click-button

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!