as3加按钮的方法是:
先给的按钮起个名字,比如叫btn
btn.addEventListener(MouseEvent.CLICK,btnClick)
function btnClick(e:MouseEvent){
stop()//这里就是点击后的动作
}
MouseEvent.CLICK是点击
MouseEvent.ROLL_OVER是鼠标放上
MouseEvent.ROLL_OUT是鼠标离开
还有一些不常用的,可以看下帮助
首先要知道你的主页是在帧上还是在另一个场景里?如果是在帧上的话:
Button.addEventListener(MouseEvent.CLICK,fanhui)
fanhui(e:MouseEvent):void{
gotoAndPlay(帧)
}
如果在另一场景,那个场景一定要有stop()
然后在当前场景输入:
Button.addEventListener(MouseEvent.CLICK,fanhui)
fanhui(e:MouseEvent):void{
gotoAndPlay(帧,场景名)
}
btn0到btnz 加上侦听事件。在共有事件里用var key=e.currentTarget .name.substr(3,1) 可以得到键盘按钮值。最后 : 文本框.text=keybtn0.addEventListener(MouseEvent.CLICK,inputphone)
btn1.addEventListener(MouseEvent.CLICK,inputphone)
btn2.addEventListener(MouseEvent.CLICK,inputphone)
btn3.addEventListener(MouseEvent.CLICK,inputphone)
btn4.addEventListener(MouseEvent.CLICK,inputphone)
btn5.addEventListener(MouseEvent.CLICK,inputphone)
btn6.addEventListener(MouseEvent.CLICK,inputphone)
btn7.addEventListener(MouseEvent.CLICK,inputphone)
btn8.addEventListener(MouseEvent.CLICK,inputphone)
btn9.addEventListener(MouseEvent.CLICK,inputphone)
btna.addEventListener(MouseEvent.CLICK,inputphone)
.......
btnz.addEventListener(MouseEvent.CLICK,inputphone)
btndel.addEventListener(MouseEvent.CLICK,del)
//input key
function inputphone(e:MouseEvent)
{
if (txtinput.text.length <11)
{
var key = e.currentTarget.name.substr(3,1)
//trace(key)
txtinput.appendText(key)
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)