2012-07-23 20 views
9

我是新來的flex,並試圖寫一些演示應用程序。現在我有一個非常新手的問題:如何在Flex應用程序中輸出一些日誌到控制檯(或者我可以看到的其他地方)?如何在開發Flex應用程序時將某些日誌輸出到控制檯?

在其他語言中,我可以使用:

System.out.println("mylog"); 
console.log("mylog"); 

但我不知道該怎麼做相同的彎曲。

回答

1

最簡單的方法是使用「trace」,一個頂級函數,您可以使用它來運行IDE和Flash調試播放器。另一種解決方案是ThunderBolt記錄器。

1

我喜歡叫 「ttrace按」 一類特定的示蹤劑可以啓用和每班不適用。而且我還會爲我創建的每個函數的第一行編寫它。跟蹤一個故事經常讓我遠程調試,無法複製客戶給你的錯誤。然後,您可以啓用或禁用ttrace清理輸出,並在您正在更新或更正的區域啓用它們。

SVN: https://code.google.com/p/darceys-as3-components/

ZIP: http://code.google.com/p/darceys-as3-components/downloads/list

要使用ttrace按

// var definition 
    private var t:Ttrace; 

    // Inside constructor 
    t = new Ttrace(true,"",true,false,"Debug console title",600,300); 
    t.ttrace("hello"); 
    addChild(t); 


    // Var dump 
    t.ttrace("myvar = " + myVar); 

    // Warning 
    t.warn("warning"); 

    // Error 
    t.error("An error has occured in ......."); 

Parmaters是:

Ttrace(
     enabled:Boolean, 
     applicationName:String="", 
     useDebugBox:Boolean=false, 
     debugBoxVisible:Boolean=true, 
     debugBoxTitle:String="", 
     debugBoxWidth:Number=800, 
     debugBoxHeight:Number=400 

26

正如提到的here,你可以做到這一點

import flash.external.ExternalInterface; 
ExternalInterface.call("console.log", "YourString"); 
相關問題