关键帧在AS3设置实例名称快速实例、名称、关键、快速

2023-09-08 13:34:48 作者:╰騎著母豬闖天下☆

目前在Flash CS3及以上(使用ActionScript 3)如果你有一个用于在多个关键帧一层相同的实例,并决定转让或更高版本更改实例名称,你就必须去各个关键帧,并设置实例名称。这是一个很大的滋扰。是否有一个更快的或更好的方式来做到这一点?

Right now in Flash CS3 and up (using Actionscript 3) if you have the same instance that is used in multiple keyframes in a layer, and you decide to assign or change the instance name later, you would have to go to each keyframe and set the instance name. This is a big nuisance. Is there a quicker or better way to do this?

注:在AS2中,您可以通过使用影片剪辑的name属性在code在MovieClip类的onLoad处理,所以它做一劳永逸设置名称。不幸的是在AS3中,你不允许再设置name属性。

NOTE: In AS2, you can set the name by using name property of the MovieClip in your code in the onLoad handler of the MovieClip class so it's done once and for all. Unfortunately in AS3, you are not allowed to set the name property anymore.

推荐答案

您可以使用JSFL,在Flash中的JavaScript为基础的自动化lanaguage,自动执行任务是这样的。

You can use JSFL, a javascript-based automation lanaguage in Flash, to automate tasks like this.

单击文件>新建 选择闪光的JavaScript文件,从列表中 粘贴下面的脚本 确保您在FLA文件中选择您的实例 点击运行(播放)按钮,在JSFL脚本文件

您就可以使用下面的code到名称与preFIX和索引号的所有选定的实例:

You can then use the following code to name all selected instances with a prefix and an an index number:

var prefix:String = "myInstance_";
for(i in fl.getDocumentDOM().selection)
{
    fl.getDocumentDOM().selection[i].name = prefix + i.toString();
}

这将导致你的情况下被命名myInstance_1,myInstance_2等,这主要是一个例子,为您扩展您的特定需求。

This will result in your instances being named myInstance_1, myInstance_2, etc. This is mainly an example for you to extend to your specific needs.

(需要注意的一点fl.trace()是你如何打印跟踪,当你在调试JSFL消息,我花了一段时间来弄清这一点)的