flash-console  这是一个用于调试swf的类库,用于添加到舞台上使用 使用方法非常的简单

1
2
import com.junkbyte.console.Cc;
Cc.startOnStage(this, "");

以上代码就能让调试面板在舞台上显示出来, 如果想在面板上输出log信息,可以用一下语句

1
2
3
4
Cc.config.commandLineAllowed = true // Enables full commandLine features
Cc.config.tracing = true; // also send traces to flash's normal trace()
Cc.config.maxLines = 2000; // change maximum log lines to 2000, default is 1000
Cc.config.commandLineAutoScope = true;  //自动切换命令行当前域(比较有用)

还可以根据自己的需要对调试面板进行一下属性设置

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
//start之前的配置
Cc.config.commandLineAllowed = true // Enables full commandLine features
Cc.config.tracing = true; // also send traces to flash's normal trace()
Cc.config.maxLines = 2000; // change maximum log lines to 2000, default is 1000

Cc.startOnStage(this); // finally start with these config

//start之后的设置
Cc.commandLine = true;
Cc.width = 460;
Cc.height = 500;

下面是命令行的使用

  • 默认的scope是stage,在命令行输入width,回车可以打印stage的width属性
  • 输入过程是有提示的,按tab可以实现自动补全
  • 另外使用/command命令可以查看内置的一下命令

我们还可以查看和调用自身内部对象的属性和函数, 例如我们有自己的类

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
class InnerData {
    public var va:int;
    public var vb:String;

    public function InnerData() {
        va = 10;
        vb = "hello word";
        }

    public function sum(a:int, b:int):int {
        return a + b;
    }

}

首先要注册带Cc中

1
Cc.store("inner", new InnerData ());

在运行过程中,命令行中输入$inner,回车

这时候会切换到我们的内置数据结构中,我们可以通过代码调用sum函数

1
sum(10,19)

命令行会返回给我们结果.

还有很多强悍的功能,例如watch,官网写的都很详细

演示程序