使用 ActionScript 3.0 对链接的 SWC 进行运行时自省闪存/柔性

发布于 2024-09-26 09:57:16 字数 557 浏览 0 评论 0原文

哇,这是我在 Stack Overflow 上的第一篇文章。我“到”了吗?

好吧,这是一个奇怪的事情。我试图确定是否有某种编程方式可以在运行时内省链接的 SWC 中的类。

为了提供更多背景知识(也许有一种完全不同的方法来做到这一点),我正在考虑字体嵌入的通用框架。目前,要嵌入字体(使用链接的 SWC,而不是 [embed] 元标记),您需要使用 Flash IDE 将字体嵌入到 SWC 中,然后需要在您的文件中硬编码对库资源的类的引用。代码(可能是由其他人使用不同的 IDE 创建的 - 例如 FlashDevelop)。

现在,如果可以在运行时内省 SWC 并迭代它公开的类,理论上可以以编程方式实例化/注册这些字体,而不必(在编译时)知道这些字体可能是什么。

因此问题是:有谁知道有什么方法可以在运行时将 SWC 作为实体访问并内省其公开的类吗?


顺便说一句,此类事情的基本原理是对设计和应用程序逻辑职责的清晰分离的简单愿望。设计人员可以轻松嵌入字体、作者和 SWC,还可以编辑相应的外部 CSS 文件。指望他们更新代码中类的硬引用,或者指望客户在编译和发布作业后不改变对字体使用的想法,要危险得多。

Wow, my first post on Stack Overflow. Have I "arrived"?

Okay, this is an oddball. I'm trying to determine whether there might be some programmatic way to introspect the classes within a linked SWC at runtime.

To give a little more background (maybe there's a completely different way to go about doing this), I'm considering a general framework for Font Embedding. Currently, to embed fonts (using a linked SWC, not the [embed] metatag), you need to embed the font in your SWC using the Flash IDE, and then you need to hard-code a reference to the library asset's Class in your code (possibly being created by someone else, using a different IDE - FlashDevelop for instance).

Now, if it were possible at runtime to introspect the SWC and iterate through the classes it exposes, one could theoretically instantiate/register these fonts programatically without having to know (at compile time) what those fonts might be.

Hence the question: does anyone know of any way to access the SWC as an entity at runtime and introspect its exposed Classes?


As an aside, the rationale for this sort of thing is a simple desire for clean separation of design and application logic responsibilities. It's easy for a Designer to embed the font and author and SWC, and also edit a corresponding external CSS file. It's much more dangerous to count on them to update the hard references to the classes in code, or count on the client not changing their mind about the font usage after the job has been compiled and released.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

满身野味 2024-10-03 09:57:16

您可以将文件作为二进制文件加载(或者如果它是主文件,则使用阶段的 LoaderInfo 的 bytes 属性),查看 ABC 数据的“标签”,解析它,然后查找所需的数据。虽然这很麻烦。

有诸如字体标签之类的东西。 DefineFont2(标签类型48)包含FontID和FontName,DefineFontName(标签类型88)也包含FontID和FontName。也许这就是您需要的数据。如果是这样,那么即使是最大的文件,浏览起来也会非常快。

您可以在此处阅读 .swf 文件格式规范: http://www.adobe.com/devnet /swf.html

You could load the file in as a binary (or use the bytes property of the stage's LoaderInfo if it's the main file), look through the 'tags' for the ABC data, parse it, and look for the data you need. It is a hassle though.

There are such things as font tags. DefineFont2 (tag type 48) which contains a FontID and a FontName, DefineFontName (tag type 88) which also contains FontID and FontName. Maybe that's the data you need. If it is, then it can be insanely quick to look through even the largest of files.

You can read through the .swf file format specification here: http://www.adobe.com/devnet/swf.html

夏雨凉 2024-10-03 09:57:16

您应该查看 FLexSpy (fxspy) http://code.google.com/p/fxspy/

还有其他一些也会有帮助:

KapInspect: http:// lab.kapit.fr/display/kapinspect/Kap+Inspect

DeMonster DeBugger:http://demonsterdebugger.com/

You should look at FLexSpy (fxspy) http://code.google.com/p/fxspy/

There are some others out there that will be helpful, too:

KapInspect: http://lab.kapit.fr/display/kapinspect/Kap+Inspect

DeMonster DeBugger: http://demonsterdebugger.com/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文