2014-09-02 54 views
-1

我遇到了使用trace()的問題;跟蹤不能在Actionscript 3中使用Flash CS5

例如,在我的項目(和其他項目)中的多個點上,我有跟蹤語句,直到最近纔開始工作。出於某種原因,在之前工作過的相同項目中,跟蹤不再在「輸出」窗口中顯示任何內容。

我已經確認並做了以下內容:

  1. 證明:對於輸出濾波器是無或放牧
  2. 我發佈預覽到Flash,HTML不
  3. 在發佈設置選項卡,「忽略跟蹤動作」未被選中
  4. 已驗證我通過雙擊Flashplayer窗口進行雙擊檢查並看到「調試器」選項,從而驗證了Flash Player調試器。
  5. 重置工作區,以防萬一有什麼奇怪的事情發生。
  6. 閱讀StackOverflow中關於同一問題的其他3篇文章,嘗試了每個人的解決方案,但尚未得到它的工作。

有沒有人有任何想法?我添加了完整的代碼。

package 
{ 
//importing classes 
import flash.display.Sprite; 
import flash.events.MouseEvent; 
import flash.events.TimerEvent; 
import flash.utils.Timer; 
import flash.events.Event; 
//END importing classes 
public class Main extends Sprite 
{ 
    //class level variables 
    private const FIELD_W:uint=9; 
    private const FIELD_H:uint=9; 
    private const NUM_MINES:uint=10; 
    private var mineField:Array=new Array(); 
    private var game_container:Sprite=new Sprite(); 
    private var tile:tile_movieclip; 
    private var timer:Timer=new Timer(1000); 
    private var toolbar:toolbar_mc; 
    private var gameOver:Boolean=false; 
    private var firstClick:Boolean=true; 
    private var remainingTiles:uint=FIELD_W*FIELD_H; 
    private var minesLeft:uint=NUM_MINES; 
    private var screenFrame:Screens; 
    //END class level variables 

    public function Main() 
    { 

     //Mine Field Creation 
     for (var i:uint=0; i<FIELD_H; i++) 
     { 
      mineField[i]=new Array(); 
      for (var j:uint=0; j<FIELD_W; j++) 
      { 
       mineField[i].push(0); 
      } 

     } 
     trace("My dangerous mine field: "+mineField); 
       //END Mine Field Creation 

     addChild(game_container); 

     for (i=0; i<FIELD_H; i++) 
     { 
      for (j=0; j<FIELD_W; j++) 
      { 
      tile = new tile_movieclip(); 
      game_container.addChild(tile); 
      tile.gotoAndStop(1); 
      tile.nrow=i; 
      tile.ncol=j; 
      tile.buttonMode=true; 
      tile.x=tile.width*j; 
      tile.y=tile.height*i; 
      tile.addEventListener(MouseEvent.CLICK,onTileClicked); 
      } 
     } 
     // end of tile creation 
     //time amangement and game over 
     toolbar = new toolbar_mc(); 
     addChild(toolbar); 
     //var s_height:uint= stage.height; 
     toolbar.y=725; 
     timer.start(); 
     timer.addEventListener(TimerEvent.TIMER,onTick); 
     //end of time management and game over 

    }//END Main function 
    private function onTick(e:TimerEvent):void 
    { 
     toolbar.message_text.text="Elapsed time: "+timer.currentCount+"s"; 
     //trace("Elapsed time: "+timer.currentCount); 
    } 
    private function tileValue(row,col:uint):int 
    { 
     if (mineField[row]==undefined || mineField[row][col]==undefined) 
     { 
      return -1; 
     } 
     else 
     { 
      return mineField[row][col]; 
     } 
    } 
    private function onTileClicked(e:MouseEvent):void 
    { 
     if (!gameOver && remainingTiles > 0) 
     { 

      var clicked_tile:tile_movieclip=e.currentTarget as tile_movieclip; 
      clicked_tile.removeEventListener(MouseEvent.CLICK,onTileClicked); 
      clicked_tile.buttonMode=false; 
      var clickedRow:uint=clicked_tile.nrow; 
      var clickedCol:uint=clicked_tile.ncol; 
      var clickedValue:uint=mineField[clickedRow][clickedCol]; 
      if (firstClick) 
      { 
       firstClick=false; 
       //placing mines 
       var placedMines:uint=0; 
       var randomRow,randomCol:uint; 
       while (placedMines<NUM_MINES) 
       { 
        randomRow = Math.floor(Math.random()*FIELD_H); 
        randomCol = Math.floor(Math.random()*FIELD_W); 
        if (mineField[randomRow][randomCol] ==0) 
        { 
         if (randomRow!=clickedRow||randomCol!=clickedCol) 
         { 
          mineField[randomRow][randomCol] = 9; 
          placedMines++; 
         } 
        } 
       }//END placing Mines 
       // placing digits 
       for (var i:uint=0; i<FIELD_H; i++) 
       { 
       for (var j:uint=0; j<FIELD_W; j++) 
       { 
        if (mineField[i][j]==9) 
        { 
         for (var ii:int =-1; ii<=1; ii++) 
         { 
          for (var jj:int =-1; jj<=1; jj++) 
          { 
           if (ii!=0||jj!=0) 
           { 
            if (tileValue(i+ii,j+jj)!=9&&tileValue(i+ii,j+jj)!=-1) 
            { 
             mineField[i+ii][j+jj]++; 
            } 
           } 
          } 
         } 
        } 
       } 
      } 
       var debugString:String; 
       trace("My complete and formatted mine field: "); 
       for (i=0; i<FIELD_H; i++) 
       { 
        debugString=""; 
        for (j=0; j<FIELD_W; j++) 
        { 
        debugString+=mineField[i][j]+" "; 
        } 
        trace(debugString); 
       } 
       // end of placing digits 

       // tile creation 
        } 
        if (e.shiftKey) 
        { 
         clicked_tile.gotoAndStop(5-clicked_tile.currentFrame); 
         remainingTiles--; 
         if (remainingTiles ==0) 
          { 
           timer.stop(); 
           //Create a for loop involving string for number that appears on tiles 
           toolbar.message_text.text="WinBomb"; 
           screenFrame = new Screens(); 
           game_container.addChild(screenFrame); 
           screenFrame.gotoAndStop("win"); 
          }        
         if (clickedValue ==9) 
         { 
          minesLeft--; 
          if (minesLeft==0) 
           { 
            timer.stop(); 
            //Create a for loop involving string for number that appears on tiles 
            toolbar.message_text.text="Mine Free!!"; 
            removeChild(toolbar); 
            screenFrame = new Screens(); 
            game_container.addChild(screenFrame); 
            screenFrame.gotoAndStop("win"); 
           }        
         } 
        } 
        else 
        { 
         //empty tile 
         if (clickedValue == 0) 
         { 
          floodFill(clickedRow,clickedCol); 
         }//END empty Tile 
         // numbered tile 
         if (clickedValue>0&&clickedValue<9) 
         { 
          clicked_tile.gotoAndStop(2); 
          clicked_tile.tile_text.text=clickedValue.toString(); 
          remainingTiles--; 
          if (remainingTiles ==0) 
          { 
           toolbar.message_text.text="Mine Free!!"; 
           removeChild(toolbar); 
           screenFrame = new Screens(); 
           game_container.addChild(screenFrame); 
           screenFrame.gotoAndStop("win"); 
          } 
         }// end of numbered tile 
         // mine 
         if (clickedValue==9) 
         { 
          clicked_tile.gotoAndStop(3); 
          timer.removeEventListener(TimerEvent.TIMER,onTick); 
          removeChild(toolbar); 
          screenFrame = new Screens(); 
          game_container.addChild(screenFrame); 
          screenFrame.gotoAndStop("lose"); 
          /*timer=new Timer(5000); 
          timer.start(); 
          trace("Timer to End: "+timer.currentCount); 
          timer.addEventListener(TimerEvent.TIMER_COMPLETE, loseScreen);        screenFrame = new Screens(); 
          */ 
         }// end of mine 
        } 
       } 
     else if (remainingTiles == 0) 
     { 
      timer.stop(); 
      toolbar.message_text.text="Mine Free!!"; 
      removeChild(toolbar); 
      screenFrame = new Screens(); 
      game_container.addChild(screenFrame); 
      screenFrame.gotoAndStop("win"); 
     } 

    }//END onTileClicked function 
    private function floodFill(row,col:uint):void 
    { 
     var emptyTile:tile_movieclip; 
     emptyTile=game_container.getChildAt(row*FIELD_W+col) as tile_movieclip; 
     if (emptyTile.currentFrame==1) 
     { 
      emptyTile.removeEventListener(MouseEvent.CLICK,onTileClicked); 
      emptyTile.buttonMode=false; 
      emptyTile.gotoAndStop(2); 

      if (mineField[row][col]>0) 
      { 
       emptyTile.tile_text.text=mineField[row][col].toString(); 
       remainingTiles--; 
      } 
      else 
      { 
       emptyTile.gotoAndStop(5); 
       remainingTiles--; 

      } 
      if (mineField[row][col]==0) 
      { 
       for (var ii:int =-1; ii<=1; ii++) 
       { 
        for (var jj:int =-1; jj<=1; jj++) 
        { 
         if (ii!=0||jj!=0) 
         { 
          if (tileValue(row+ii,col+jj)!=9) 
          { 
           if (tileValue(row+ii,col+jj)!=-1) 
           { 
            floodFill(row+ii,col+jj); 
           } 
          } 
         } 
        } 
       } 
      } 
     } 
    }//END floodFill 
/* private function loseScreen(e:TimerEvent) 
    { 
     timer.removeEventListener(TimerEvent.TIMER_COMPLETE, loseScreen); 
     game_container.addChild(screenFrame); 
     screenFrame.gotoAndStop("lose"); 
    }*/ 
}//END Main CLass 

}//END package 
+1

您是否確定您追蹤的線路已到達? – BadFeelingAboutThis 2014-09-02 22:35:23

+0

代碼?簡化,如果可能的話? – Craig 2014-09-03 02:10:50

+0

現在添加代碼,這用於在輸出中顯示跟蹤,現在不會,代碼也沒有更改。 @Craig – 2014-09-03 13:38:57

回答

0

查看代碼的頂部,這裏有一個輕微的重新安排。在這個實驗中,我已經開始初始化'_FIELD'變量的自由。嘗試一下。這是否能解決您的問題?

var mineField:Array = new Array;   
var FIELD_H:int = 10; 
var FIELD_W:int = 20; 

for (var i:uint=0; i<FIELD_H; i++) 
{ 
    mineField[i]=new Array(); 
    for (var j:uint=0; j<FIELD_W; j++) 
    { 
     mineField[i].push(0); 
    } 

} 

trace(mineField); 
+0

它不,仍然沒有跟蹤輸出。 – 2014-09-04 14:14:46

+0

有趣。你可以跟蹤另一個.fla文件中的任何東西嗎?嘗試設置一個新的.fla,沒有外部代碼,只需將trace(「我可以讀這個」)寫入actionscript(F9)面板。如果沒有跟蹤,請查看發佈設置。在「高級」下,確保「忽略跟蹤語句」未被選中。如果問題仍然存在,則會發送導致問題的最小代碼。 – Craig 2014-09-04 16:50:44

+0

我無法追蹤任何FLA中的任何內容。我創建了一個新的fla,並在動作選項卡中放置了跟蹤(「hi」);仍然沒有。 – 2014-09-04 20:55:44

0

首先

Main Class不正確寫入。如果它已導入,則編譯器應輸出以下內容:error message

1114:公共屬性只能在包內使用。

因爲一個類的一般形式是:

package myPackage 
{ 
    class MyClass 
    { 
    } 
} 

在另一方面

具體來說,這error message不會發生,因爲你沒有可能導入了Main class

文件>動作設置>文檔分類:Main

+0

我不明白,程序沒有錯誤或警告。我現在已經把所有的代碼放到了你的編譯器中。 – 2014-09-04 16:08:28

+0

你還沒有導入你的班級。您的'Main'類是否出現在「ActionScript設置」面板上?就像我說過的,如果這個類被導入,你的編譯器應該輸出一個錯誤信息,因爲你的類沒有被正確寫入(包到一個包中)。 – helloflash 2014-09-04 16:13:12

+0

@Mark Rivinius - 如果您在未回答我的ActionScript Panel問題的情況下編輯您的問題(在我的評論之後添加軟件包),將很難解決您的問題! – helloflash 2014-09-04 18:05:02

相關問題