trace 函数

trace(expression:Object)

可以使用 Flash 调试播放器捕获 trace() 函数的输出,并将该输出写入到日志文件中。

语句;在测试模式中,计算表达式并在"输出"面板中显示结果。

在测试 SWF 文件时,使用此语句可在"输出"面板中记录编程注释或显示消息。使用 expression 参数可以检查是否存在某种条件,或在"输出"面板中显示值。trace() 语句类似于 JavaScript 中的 alert 函数。

可以使用"发布设置"对话框中的"省略跟踪动作"命令将 trace() 动作从导出的 SWF 文件中删除。

参数

expression:Object ― 要计算的表达式。在 Flash 创作工具中打开 SWF 文件时(使用"测试影片"命令),expression 参数的值显示在"输出"面板中。

示例

下面的示例使用 trace() 语句在"输出"面板中显示动态创建的名为 error_txt 的文本字段的方法和属性:

this.createTextField("error_txt", this.getNextHighestDepth(), 0, 0, 100, 22);
for (var i in error_txt) {
trace("error_txt."+i+" = "+error_txt[i]);
}
/* output:
error_txt.styleSheet = undefined
error_txt.mouseWheelEnabled = true
error_txt.condenseWhite = false
...
error_txt.maxscroll = 1
error_txt.scroll = 1
*/