◆ 网页平面多媒体培训、认证考试免费咨询热线:400-700-5807 进入网络咨询平台 ◆
附带的说一句,这个脚本用了member.type 属性来检查某成分是否被看成是一个位图。这样的检查通常很有用。这里是这种模型的最后一个例子:写一个程序去转换你所有的文本text成员到field成员, 保留基本的格式。这里用一些新的命令创建一个全新的计算成分,一项非常强大的技术。脚本里也包含了两个附加的选项:是否保留一份原始成分的副本,和新的域是否应该和原始成分放在同一计算成分位置里。这两项默认为是。 on converttofield lib, retain, sameplace if voidp (lib) then lib = the activecastlib if voidp (retain) then retain = 1 if voidp (sameplace) then sameplace = 1 s=castlib (lib).selection repeat with lyst in s repeat with i = lyst[1] to lyst[2] mem=member (i, lib) if mem.type <> #text then next repeat if sameplace then newmem = new (#text) newmem.media = mem.media newmem.name = mem.name erase mem mem=newmem f=new (#field, member (i, lib)) else f = new (#field) end if f.text = mem.text f.rect=mem.rect f.alignment = string (mem.alignment) f.name = mem.name repeat with k = 1 to mem.text.length the font of char k of field f = mem.char[k].font the fontsize of char k of field f = mem.char[k].fontsize s = mem.char[k].fontstyle tx = '''' repeat with sym in s tx = tx & sym & '','' end repeat if tx.length > 0 then delete tx.char[tx.length] the fontstyle of char k of field f = tx end if end repeat if not retain then erase mem end repeat end repeat end
选择你感兴趣的CAST成员不是进行复杂搜索的唯一方法,顺便一提-Lingo 存诸了CAST成员的所有工具。你可以用creationDate 属性去改变上个星期才输入的CAST成员,或是用modifiedBy 属性去改变那些还没有被修改过的CAST。 快速绘图
创作脚本不仅仅在适应或改变现有的ASSETS上有作用。你也可以用它们创建图形。最近,我在一个教育站点从事包括大量几何图形的数学的工作,而且很快我便厌烦了用Photoshop 创建图形。所以我创建了一些程序使我被允许在Director 中画几何图形。这里是一个例子: on drawsquare w, nm, col, bg, s v=new (#vectorshape) v.vertexlist = [[#vertex: point (0, 0)], [#vertex: point (0, w)], [#vertex: point (w, w)], [#vertex: point (w, 0)]] if voidp (bg) then bg = rgb (255, 255, 255) if voidp (col) then col = rgb (0, 0, 0) if voidp (s) then s = 1 v.backgroundcolor = bg v.strokecolor = col v.strokewidth = s v.closed = 1 v.fillmode = #none mem = new (#bitmap) mem.image = v.image mem.name = string (nm) erase v end 这个例子相当的简单,但是你可以用这个程序很长时间。那么,这个怎么样:一种画曲径的方法。我们用这种形式的数据清单供给它:[[1,2],[0,1]]。每一个数字代表曲径里一个单一的正方形,and has a value representing whether there is a wall to the right or to the right or to the bottom of that square. 因此: 0 = exit at bottom and right 1 = exit at bottom 2 = exit at right 3 = no exit to bottom or right 我们不必担心会离开当前命令行外壳到顶部或是左边,因为那是多余的,并且我们假定曲径在每 一边都是关闭的。我们可以开始画了。 on drawmaze m, w if voidp (w) then w = 20 vert = m.count hor = m[1].count maze = image (w * hor + 1, w * vert + 1, 16) repeat with i = 1 to vert repeat with j = 1 to hor sq = m[ i ][j] if sq mod 2 or i = vert then maze.draw ((j - 1) * w, i * w, j * w, i * w + 1, rgb (0, 0, 0)) if sq > 1 or j = hor then maze.draw (j * w, (i - 1) * w, j * w + 1, i * w, rgb (0, 0, 0)) end repeat end repeat maze.draw (0, 0, 1, w * vert, rgb (0, 0, 0)) maze.draw (0, 0, w * hor, 1, rgb (0, 0, 0)) mem = new (#bitmap) mem.image = maze end 试着做-在信窗口里写入: drawmaze ([[1,0,3,0],[0,3,0,0],[0,0,2,0]]) 检查你的内在成员Internal cast且一个新的曲径已经添加了。顺便提一下,这项技术不仅仅用于创作-它也可以用于运行时间,来保存文件大小。但是不要忘记你在运行时间里添加的每一个新的cast成员在被擦除之前都会在内存中,所以它可能在执行时产生影响。请确信在用完你的CAST成员后清除它们。 上一页 [1] [2]
 【责编:runlz】 |