作者lovesaber (幻想神)
看板Flash
標題[問題]flash程式碼問題
時間Tue Apr 9 22:00:28 2013
程式碼如下:
-----------------------------------
const colors:int = 4;
const x_num:int = 10;
const y_num:int = 10;
var colorNum:int;
for (var i:int = 0; i <= (x_num+1); i++) {
for (var j:int = 0; j <= (y_num+1); j++) {
this["block" + i + "_" + j] = new block_mc();
this["block" + i + "_" + j].x = i * 45;
this["block" + i + "_" + j].y = j * 43;
this["block" + i + "_" + j].bx = i;
this["block" + i + "_" + j].by = j;
this["block" + i + "_" + j].bc = 0;
this["block" + i + "_" + j].gotoAndStop("無方塊");
this.addChild(this["block" + i + "_" + j]);
}
}
for (i=1; i<=x_num; i++) {
this["newBlock" + i] = new block_mc();
this["newBlock" + i].alpha = 0.2;
this["newBlock" + i].x = i * 45;
this["newBlock" + i].y = 480;
this["newBlock" + i].gotoAndStop("無方塊");
this.addChild(this["newBlock" + i]);
}
reset_btn.addEventListener(MouseEvent.CLICK, gameReset);
quit_btn.addEventListener(MouseEvent.CLICK, gameQuit);
function clickBlock(event:MouseEvent) {
var bx:int = event.target.bx;
var by:int = event.target.by;
var bc:int = event.target.bc;
if ( bc > 0 ) {
for (var i:int = 0; i <= (x_num+1); i++) {
for (var j:int = 0; j <= (y_num+1); j++) {
this["temp" + i + "_" + j] = this["block" + i + "_" + j].bc;
}
}
colorNum = 0;
searchBlock(bx,by,bc);
if ( colorNum >=3 ) {
gotoAndPlay("異動更新");
}
}
}
function showButton(event:MouseEvent) {
var bc:int = event.target.bc;
if ( bc > 0 ) {
event.target.buttonMode = true;
}
}
function searchBlock(b_x, b_y, b_c:int) {
colorNum ++;
this["temp" + b_x + "_" + b_y] = 0;
if (this["temp" + (b_x + 1) + "_" + b_y] == b_c) {
searchBlock(b_x + 1, b_y, b_c); // right
}
if (this["temp" + (b_x - 1) + "_" + b_y] == b_c) {
searchBlock(b_x - 1, b_y, b_c); // left
}
if (this["temp" + b_x + "_" + (b_y - 1)] == b_c) {
searchBlock(b_x, b_y - 1, b_c); // up
}
if (this["temp" + b_x + "_" + (b_y + 1)] == b_c) {
searchBlock(b_x, b_y + 1, b_c); // down
}
}
function gameReset(event:MouseEvent) {
gotoAndPlay("遊戲開始");
}
function gameQuit(event:MouseEvent) {
fscommand ("quit");
}
--------------------------------------------
當我按下quit_btn這個按鈕的時候
完全不會關閉視窗
完全沒有反應
跪求高手解決
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.224.245.123
1F:→ viceversa56:1.建議改標題關於fscommand語法,後面的人會比較好爬文 04/14 22:33
2F:→ viceversa56:2.我發佈後是可關閉,fscommand不能在CTRL+ENTER下執行 04/14 22:33
3F:→ viceversa56:發布成EXE或Swf file下即可執行 04/14 22:35
4F:→ lovesaber:發佈成exe或者swf也一樣 04/18 18:33