无法访问 SWC 中的媒体资产
我在访问 SWC 中的内容时遇到问题。主项目编译没有错误,但资产(声音、音乐)未显示或播放。
:
我的工作流程 使用 Flash CS5
1.创建MAsset.fla
2.导入声音、艺术
3.指定类名,在第1帧中勾选导出
4a.写出第 1 帧操作面板中的类
4b.或者。添加文档类并在那里写出类
5.导出SWC。文件大小与我直接导入主项目库中的资源时的大小类似。
6. 创建Project.fla和文档类Project.as
7. 通过Actionscript面板将SWC导入到主项目中。
8. 添加代码,从 SWC 调用类名(例如 DCL_UI_MOUSE)
9. 编译。
没有编译器错误,但什么也没做。生成的 SWF 文件大小仅反映主项目中编译后的代码。
关于步骤 4,如果我只是在根时间轴或文档类中写入类名,编译器错误将会消失,并且资产似乎是在 SWC 中编译的。但我也尝试过:
var asset0000:DCL_UI_MOUSE;
并且:
var asset0000:DCL_UI_MOUSE = new DCL_UI_MOUSE();
无论如何,这些资源都不会进入最终的 SWF。
我做错了什么?
I'm having trouble accessing content in an SWC. The main project compiles without error, but the assets (sound, music) aren't displayed or played.
My workflow:
i. Using Flash CS5
1. Create MAsset.fla
2. Import sounds, art
3. Assign class names, check export in frame 1
4a. Write out the classes in the actions panel in frame 1
4b. OR. Add a document class and write out the classes there
5. Export SWC. Filesize is similar to what it is when I directly import assets in the main project library.
6. Create Project.fla and document class Project.as
7. Import SWC into main project through the Actionscript panel.
8. Add code, which calls the class names from the SWC (e.g. DCL_UI_MOUSE)
9. Compile.
No compiler errors, but nothing doing. And the resulting SWF filesize doesn't reflect anything more than the compiled code from the main project.
Regarding step 4, if I just write the class name in the root timeline or document class, the compiler error will go away and the asset appear to be compiled in the SWC. But I have also tried:
var asset0000:DCL_UI_MOUSE;
And:
var asset0000:DCL_UI_MOUSE = new DCL_UI_MOUSE();
Regardless the assets don't make it into the final SWF.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您说“通过 ActionScript 面板将 SWC 导入主项目”和“添加代码,从 SWC 调用类名”时,您到底是什么意思?
如果要将 SWC 用作资源库,则必须
import
语句添加到 ActionScript 代码中。没有第三步™。
您还可以通过链接到属性面板中的各个库对象来将其用作运行时共享库。
要将库项目编译到 SWC 中,请选中“导出为 ActionScript”和“导出到第 1 帧”,然后将完全限定的类名写入“类”字段。 “基类”应设置为 flash.display.MovieClip 或 flash.display.Sprite(对于 MovieClip 项目)或 flash.display.SimpleButton(对于 Button 项目) - 以最适合对象的方式为准。
另请注意,类名通常使用驼峰式大小写(例如:DclUIMouse)。命名常量时将使用全部大写的 DCL_UI_MOUSE。
What exactly do you mean when you say "Import SWC into the main project through the ActionScript panel" and "Add code, which calls the class names from the SWC"?
If you want to use an SWC as an asset library, you have to
import
statements to your ActionScript code.There's no step three™.
You can also use it as a runtime shared library by linking to individual library objects in the properties panel.
To get your library items to compile into the the SWC, check "export for ActionScript" and "export in frame 1", then write your fully qualified class name into the "class" field. "Base class" should be set to flash.display.MovieClip or flash.display.Sprite (for MovieClip items), or flash.display.SimpleButton (for Button items)- whichever fits the object best.
Also, note that it is customary to use camel case for class names (eg: DclUIMouse). The all caps DCL_UI_MOUSE would be used when naming a constant.