1.求AS3.0制作的flash小游戏连连看的源文件
2.flash AS3.0开发的程序实现退出程序的代码怎么写?
3.你好。flash as3.0小游戏,要源代码,类似于连连看,打砖块之类的。能发我吗?
求AS3.0制作的flash小游戏连连看的源文件
百度来的,希望能帮到你
as3.0-------------数字连连看的易语言按钮源码实现
这里用到2个文件,.fla和.ActionScripte。freertos 源码风格这两个文件一定要放在同一个文件夹下
第一:创建一个名为LMC的ActionScripte文件,代码如下:
package
{
import flash.display.MovieClip;
import flash.text.TextField;
import flash.display.Sprite;
import flash.events.MouseEvent;
public class LMC extends MovieClip
{
public function LMC(str:String):void
{
init(str);
}
private function init(str:String):void
{
txt.mouseEnabled = false;
txt.selectable = false;
txt.text = str;
this.addEventListener(MouseEvent.MOUSE_OUT,out);
this.addEventListener(MouseEvent.MOUSE_OVER,over);
}
private function out(evt:MouseEvent):void
{
}
private function over(evt:MouseEvent):void
{
}
}
}
第二:创建一个.fla文件(文件名我这里是lianliankan,随个人习惯),在舞台创建2个文本其中动态文本的实例名为“num”,
第三,新建元件名为LMC的影片剪辑,里面创建三个图层,问道1.41源码背景第四帧只要改一下颜色为蓝色就行了,至于代码层都为 stop();
第四,打开库,右击LMC----->链接----->链接属性的swapid c源码类名改为:LMC,其他不变----->确定
第五,回到舞台,创建一个代码图层,如图:
第六,开源码好处代码如下:
import LMC;//导入LMC类
var num_i:uint = 0;
var lmc:LMC;//缓存用的
var arr:Array=new Array();
var c:Array=new Array();
var left:uint = 0;
var top:uint = 0;
for (var i:uint=0; i<; i++)
{
var a:LMC = new LMC(String(Math.floor(Math.random() * )));
if (left+a.width>)
{
left = 0;
top += a.height;
}
a.x = left;
a.y = top;
left += a.width;
addChild(a);
arr.push(a);
a.addEventListener(MouseEvent.MOUSE_DOWN,dian);
a.addEventListener(MouseEvent.MOUSE_OVER,over);
a.addEventListener(MouseEvent.MOUSE_OUT,out);
}
function out(evt:MouseEvent):void
{
evt.currentTarget.txt.textColor = 0xff;
}
function over(evt:MouseEvent):void
{
evt.currentTarget.txt.textColor = 0xff;
}
function dian(evt:MouseEvent):void
{
evt.currentTarget.gotoAndPlay(2);
if ((evt.currentTarget as LMC)==lmc)
{
return;
}
if (lmc==null)
{
lmc = evt.currentTarget as LMC;
}
else
{
if (lmc.txt.text == evt.currentTarget.txt.text)
{
num_i += 2;
num.text = String(num_i);
removeChild(lmc);
removeChild((evt.currentTarget as LMC));
lmc = null;
}
else
{
evt.currentTarget.gotoAndPlay(1);
lmc.gotoAndPlay(1);
lmc = null;
}
}
}
flash AS3.0开发的程序实现退出程序的代码怎么写?
代码改成如下形式:mcout.addEventListener(MouseEvent.CLICK, outkill);
function outkill(event:MouseEvent):void
{
fscommand("quit","true");
}
注意必须生成文件再测试,因为如果是预览模式下,关闭功能是不能用的。
可以参考下面的教程:
Animate CC如何实现点击按钮关闭swf窗口
如果有相关的FLASH或者Animate操作及代码方面的问题可以私信,尽心解答!
你好。flash as3.0小游戏,要源代码,类似于连连看,打砖块之类的。能发我吗?
的源码!!
package
{
import flash.display.Sprite;
import flash.events.*;
import flash.text.*;
import flash.geom.Point;
public class GameMain extends Sprite
{
private var i:int = 0;
private var j:int = 0;
private var k:int = 0;
private var tf:TextFormat = new TextFormat();
private var ContainTxt:Sprite = new Sprite();
private var arrTxt:Array = new Array();
private var arrTxtColor:Array = new Array();
private var arrTxtValue:Array = [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]];
private var arrTemp:Array = new Array(5);
private var arrValue:Array = [0, 2, 4, 8, , , , , , , , GameMain, ];
private var arrColor:Array = [0xffffff, 0x, 0xff, 0xffcc, 0xff, 0xff, 0xff, 0xff, 0xffff, 0xff, 0xff, 0xffff];
private var B_change:Boolean = false;
private var dotest:int = 0;
private var score:int = 0;
public function GameMain():void
{
Depth(); //深度管理
new_Game(); //初始化
TF1();
}
private function new_Game():void
{
stage.addEventListener(Event.ENTER_FRAME, ValueToTxt);
Create_one();
Create_one();
stage.addEventListener(KeyboardEvent.KEY_DOWN, KEYDOWN);
}
private function KEYDOWN(ekey:KeyboardEvent):void
{
switch (ekey.keyCode)
{
case :
for (j = 0; j <= 3; j++)
{
for (i = 0; i <= 3; i++)
{
arrTemp[i] = arrTxtValue[i][j];
}
arrTemp[4] = 0;
doMove();
for (i = 0; i <= 3; i++)
{
arrTxtValue[i][j] = arrTemp[i];
}
}
break;
case :
for (k = 0; k <= 3; k++)
{
for (j = 0; j <= 3; j++)
{
arrTemp[j] = arrTxtValue[k][j];
}
arrTemp[4] = 0;
doMove();
for (j = 0; j <= 3; j++)
{
arrTxtValue[k][j] = arrTemp[j];
}
}
break;
case :
for (j = 0; j <= 3; j++)
{
for (i = 0; i <= 3; i++)
{
arrTemp[i] = arrTxtValue[3 - i][j];
}
arrTemp[4] = 0;
doMove();
for (i = 0; i <= 3; i++)
{
arrTxtValue[3 - i][j] = arrTemp[i];
}
}
break;
case :
for (k = 0; k <= 3; k++)
{
for (j = 0; j <= 3; j++)
{
arrTemp[j] = arrTxtValue[k][3 - j];
}
arrTemp[4] = 0;
doMove();
for (j = 0; j <= 3; j++)
{
arrTxtValue[k][3 - j] = arrTemp[j];
}
}
break;
default:
break;
}
}
private function doMove():void
{
var temp:int = 0;
score++;
//
do
{
for (i = 0; i <= 3; i++)
{
if (arrTemp[i] == 0)
{
if (arrTemp[i] != arrTemp[i + 1])
{
arrTemp[i] = arrTemp[i + 1];
arrTemp[i + 1] = 0;
B_change = true;
}
}
}
temp++;
} while (temp <= 3);
//
do
{
for (i = 1; i < 4; i++)
{
if (arrTemp[i] == arrTemp[i - 1])
{
if (arrTemp[i] != 0)
{
arrTemp[i - 1] = arrTemp[i] * 2;
arrTemp[i] = 0;
B_change = true;
}
}
}
temp++;
} while (temp <= 3);
//
do
{
for (i = 0; i < 4; i++)
{
if (arrTemp[i] == 0)
{
arrTemp[i] = arrTemp[i + 1];
arrTemp[i + 1] = 0;
}
}
temp++;
} while (temp <= 3);
// donothing
}
private function Create_one():void
{
do
{
i = Math.floor(Math.random() * 4);
j = Math.floor(Math.random() * 4);
} while (arrTxtValue[i][j] != 0);
if (Math.random() < 0.)
{
arrTxtValue[i][j] = arrValue[1];
}
else
{
arrTxtValue[i][j] = arrValue[2];
}
}
private function ValueToTxt(e:Event):void
{
for (i = 0; i < 4; i++)
{
for (j = 0; j < 4; j++)
{
var n:int = arrValue.indexOf(arrTxtValue[i][j]);
arrTxtColor[i][j].backgroundColor = arrColor[n];
arrTxt[i][j].text = arrTxtValue[i][j];
arrTxt[i][j].setTextFormat(tf);
}
}
//
if (B_change)
{
Create_one();
B_change = false;
}
}
private function GameOver():void
{
stage.removeEventListener(Event.ENTER_FRAME, ValueToTxt);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, KEYDOWN);
}
private function TF1():void
{
tf.align = "center";
tf.bold = true;
tf.size = ;
tf.font = "Arial";
tf.color = 0xFFFFFF;
}
private function Depth():void
{
addChild(ContainTxt); //文本框容器
var Frame:Sprite = FRAME();
addChild(Frame); //结构
FrameTxt(); //文本框
}
private function FrameTxt():void
{
for (i = 0; i < 4; i++)
{
arrTxt[i] = new Array();
arrTxtColor[i] = new Array();
for (j = 0; j < 4; j++)
{
var temptxt:TextField = new TextField();
var temptxtColor:TextField = new TextField();
temptxt.selectable = temptxtColor.selectable = false;
temptxt.x = i * ;
temptxtColor.x = i * ;
temptxt.y = j * + ;
temptxtColor.y = j * ;
temptxtColor.width = temptxtColor.height = ;
temptxtColor.background = true;
ContainTxt.addChild(temptxtColor);
ContainTxt.addChild(temptxt);
arrTxt[i][j] = temptxt;
arrTxtColor[i][j] = temptxtColor;
}
}
}
private function FRAME():Sprite
{
var tempframe:Sprite = new Sprite();
for (i = 0; i <= 4; i++)
{
tempframe.graphics.moveTo(i * , 0);
tempframe.graphics.lineStyle(8, 0xCCCCCC);
tempframe.graphics.lineTo(i * , );
}
for (j = 0; j <= 4; j++)
{
tempframe.graphics.moveTo(0, j * );
tempframe.graphics.lineStyle(8, 0xCCCCCC);
tempframe.graphics.lineTo(, j * );
}
return tempframe;
}
}
}