问题
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