import flash.geom.Rectangle; //引入矩形类包 var rect:Rectangle = new Rectangle(50, 50, Stage.width-100, Stage.height-100); var speed:Number = 3; this.onEnterFrame = function() { if (Key.isDown(Key.UP)) { if (curPoint._y<=rect.top) { if (map._y>=0) { //到达上边界 map._y = 0; curPoint._y -= speed; } else { map._y += speed; } } else { curPoint._y -= speed; } } if (Key.isDown(Key.DOWN)) { if (curPoint._y>=rect.bottom) { if (map._y<=-(map._height-Stage.height)) { map._y = -(map._height-Stage.height); curPoint._y += speed; } else { map._y -= speed; } } else { curPoint._y += speed; } } if (Key.isDown(Key.LEFT)) { if (curPoint._x<=rect.left) { if (map._x>=0) { map._x = 0; curPoint._x -= speed; } else { map._x += speed; } } else { curPoint._x -= speed; } } if (Key.isDown(Key.RIGHT)) { if (curPoint._x>=rect.right) { if (map._x<=-(map._width-Stage.width)) { map._x = -(map._width-Stage.width); curPoint._x += speed; } else { map._x -= speed; } } else { curPoint._x += speed; } } }; |
工作室论坛:http://freeidea.uu1001.com
Word教程网 | Excel教程网 | Dreamweaver教程网 | Fireworks教程网 | PPT教程网 | FLASH教程网 | PS教程网 |
HTML教程网 | DIV CSS教程网 | FLASH AS教程网 | ACCESS教程网 | SQL SERVER教程网 | C语言教程网 | JAVASCRIPT教程网 |
ASP教程网 | ASP.NET教程网 | CorelDraw教程网 |