2012/05/22 | [原创]adobe Director 代码总行数统计
类别(源码下载) | 评论(0) | 阅读(204) | 发表于 16:49

最近做一个Director互动项目,需要统计总的脚本代码的行数。记得之前有人写过类似的工具。懒得去找了,自己顺手写了一个,特分享一下。如有bug欢迎指出。 

-- 代码总行数统计函数 getTotalScriptLines(tCast)

--tCast大于0时 ,返回指定编号 的演员库的总代码行数。 如:put getTotalScriptLines(1)

--tCast为字符串,返回指定名称 的演员库的总代码行数。 如:put getTotalScriptLines("TweenEngine")

--tCast等于0时 ,返回所有演员库的总代码行数。             如:put getTotalScriptLines(0)

 

on getTotalScriptLines tCast

  lineNum = 0

  if tCast > 0 then

    n = the number of members of castLib tCast

    repeat with i = 1 to n    

      if member(i, tCast).type = #script then      

        lineNum = lineNum + member(i, tCast).scriptText.line.count      

      end if    

    end repeat 

  else if tCast = 0 then

    --参数为0使用递归统计所有演员库的代码行数

    c = the number of castLibs

    repeat with i = 1 to c

      lineNum = lineNum + getTotalScriptLines(i)

    end repeat

  end if  

  return lineNum

end

 

0

评论Comments