flash 扫雷游戏AS3版

shaolei.as  是Doument class 在flash里设置一下! 我是用flex3 写的as项目!这个只是一个测试版,注释写的不多,以后改进了,再多写一点注释
转载注明 :
[url=http://51as.com/]
[color="#333399"]51as.com[/color]
[/url]
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
[SWF(width="170",height="300",backgroundColor="#ffffff",frameRate="31")]
public class shaolei extends MovieClip
{
private var mWidth:int = 10;//宽度
private var mHeight:int = 10;//高度
private var mineNum:int = 20;//雷数
private var mines:Array ;
private var txtPoint:TextField;
private var intPoint:int=0;
private var intCount:int=0;
public function shaolei():void
{
this.txtPoint = new TextField();
this.txtPoint.x =50;
this.txtPoint.y =180;
this.txtPoint.text="分数:"+intPoint.toString();
this.addChild(this.txtPoint);
var hi:Array = new Array();
hi = randMine();
mines = new Array(this.mHeight);
for(var i:int =0;ithis.mHeight;i++)
{
mines[i] = new Array(this.mWidth);
for(var j:int=0;jthis.mWidth;j++)
{
var tmp:mine = new mine();
tmp.x = i*17;
tmp.y = j*17;
mines[i][j] = tmp;
tmp.addEventListener(MouseEvent.CLICK,clickMine);
this.addChild(tmp);
}
}
for(i = 0;iint = hi[i];
var mx:int = tmpint%this.mWidth;
var my:int = Math.floor(tmpint/this.mWidth);
var m:mine = mine(mines[mx][my]) as mine;
m.isMine = -1;
setNum(mx,my);
}
}
private function clickMine(e:MouseEvent):void
{
var m:mine = mine(e.target);
m.removeEventListener(MouseEvent.CLICK,clickMine);
if(m.isMine ==-1)
{
this.intPoint=this.intPoint -100
}
else
{
this.intPoint =this.intPoint + m.isMine*10
}
if(m.isMine==0)
{
m.isMine=-2;
}
m.shwoMine();
this.txtPoint.text = "分数:"+this.intPoint.toString();
intCount++;
if(intCount==100)
{
}
}
private function setNum(mx:int,my:int
本文转自:http://www.5uflash.com/flashjiaocheng/Flash-as3-jiaocheng/982.html

你可能感兴趣的:(flash技术)