如何从动作脚本引用Flash文件自身的文件名? [英] How can I reference a Flash file's own filename from actionscript?

查看:79
本文介绍了如何从动作脚本引用Flash文件自身的文件名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的管道中,我们最终使用Toolkit for CreateJS发布HTML5.但是,使我们了解HTML5的步骤之一包括发布输出一些Javascript代码的SWF.我主要设法使用JSFL使其自动化.但是,目前我们的美术师必须在时间轴上找到一行AS3并进行手动更改,但是这会中断他们的工作流程,并且如果他们错过了它或弄乱了它,则很难捕获,因此我想实现自动化它也是:

In our pipeline, we ultimately publish HTML5 using Toolkit for CreateJS. However one of the steps to get us to that HTML5 includes publishing an SWF that outputs some Javascript code. I've mostly managed to automate this using JSFL. However, at present there is one line of AS3 that our artists have to find on the timeline and change manually, but it interrupts their workflow, and if they miss it or mess it up it is hard to catch, so I would like to automate it too:

Object(root).log.text +=  "        root.skillAnime189 = factory();\n";

从上面开始,"skillAnime189.fla"是包含此代码的.fla文件的名称.如果艺术家正在制作#189技能动画,就属于这种情况,但是如果他正在执行#304或#6或#1022(无填充),则数字会相应更改,并且他必须相应地更新该行.

From the above, "skillAnime189.fla" is the name of the .fla file which contains this code. This is the case if the artist is working on Skill Animation #189, but if he is doing #304 or #6 or #1022 (no padding) the number changes accordingly, and he has to update that line accordingly.

因此,我想将该行更改为:

So, I would like to change that line to something like:

var flaName:String = getThisFlashFileName().split(".")[0];
Object(root).log.text +=  "        root." + flaName + " = factory();\n";

但是我对如何访问包含代码的.fla文件的名称感到困惑.

but I am at a loss as to how to access the name of the .fla file containing the code.

推荐答案

获取swf名称的常用方法是解析stage.loaderInfo.url参数:

The common way to get the swf name is to parse stage.loaderInfo.url parameter:

    var url:String = stage.loaderInfo.url;
    url = url.split("?")[0];    //remove query string after "?"
    var swfname:String = url.substring(url.lastIndexOf("/")+1);
    trace(swfname);

输出:

astest.swf

但是此代码给出的是swf而不是fla,因此您需要为flas和发布的swfs保持相同的名称(通常情况下它们都是相同的,因此不应问题)

But this code gives swf but, rather than fla, so you need to maintain the same names for flas and published swfs (any case usually they are the same, so it shouldn't be the problem)

这篇关于如何从动作脚本引用Flash文件自身的文件名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆