flash怎样用按钮控制图片左右移动代码
1个回答
展开全部
import flash.display.Shape;
import flash.events.MouseEvent;
/*所有矢量图位图一起动起来!*/
var shp:Shape = new Shape ()
shp= getChildAt(0) as Shape
//按钮的命名为:btn0,btn1
btn0.addEventListener(MouseEvent.CLICK,moveLift)
btn1.addEventListener(MouseEvent.CLICK,moveRight)
function moveLift(e:MouseEvent ):void {
shp.x-=10
}
function moveRight(e:MouseEvent ):void {
shp.x+=10
}
import flash.events.MouseEvent;
/*----------------单个的可以转为元件然后命名--mc为例---------------*/
btn0.addEventListener(MouseEvent.CLICK,moveLift)
btn1.addEventListener(MouseEvent.CLICK,moveRight)
function moveLift(e:MouseEvent ):void {
mc.x-=10
}
function moveRight(e:MouseEvent ):void {
mc.x+=10
}
是不是很简单呀
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询