代码如下:
第一帧
stop();
kaishi.addEventListener(MouseEvent.CLICK, yxkaishi);
function yxkaishi(event:MouseEvent):void
{
gotoAndPlay(2);
}
第二帧
stop();
stage.addEventListener(KeyboardEvent.KEY_DOWN,boy_kz);
function boy_kz(event:KeyboardEvent):void
{
if (event.keyCode == 37)
{
if (boy.x > 350)
{
boy.x = boy.x - 150;
}
}
if (event.keyCode == 39)
{
if (boy.x < 650)
{
boy.x = boy.x + 150;
}
}
}