简体   繁体   English

flash as3 了解文档 class 路径

[英]flash as3 understanding document class paths

Sorry - I know this has been covered before but I can't get my flash file to locate and use my document class.抱歉 - 我知道这之前已经介绍过,但我无法让我的 flash 文件找到并使用我的文档 class。 This is my setup (from the root)这是我的设置(从根目录)

I have a /bin folder containing my published swf and html file (/bin/test.swf).我有一个 /bin 文件夹,其中包含我发布的 swf 和 html 文件 (/bin/test.swf)。

I have a /resources folder containing an XML file which is loaded (/resources/flar/flarConfig.xml).我有一个 /resources 文件夹,其中包含已加载的 XML 文件(/resources/flar/flarConfig.xml)。

I have a /src folder containing my fla (/src/test.fla), and a directory called examples containing the.as file I want to use for my document class (/src/examples/FLARManagerTutorial_2D.as).我有一个 /src 文件夹,其中包含我的 fla (/src/test.fla),还有一个名为 examples 的目录,其中包含我想用于我的文档 class (/src/examples/FLARManagerTutorial_2D.as) 的.as 文件。 It looks like this:它看起来像这样:

package examples {

  public class FLARManagerTutorial_2D extends Sprite {

  this.flarManager = new FlarManager("../resources/flar/flarConfig.xml)

In my flash publish settings, the class path is just "."在我的 flash 发布设置中,class 路径只是“。”

In my document class, if I input: FLARManagerTutorial_2D, I get the error:在我的文档 class 中,如果我输入:FLARManagerTutorial_2D,我会收到错误:

The name of the package 'examples' does not reflect the location of this file.

What do I need to do to get it to recognize and reference this class correctly and load the XML file?我需要做什么才能让它正确识别和引用这个 class 并加载 XML 文件? I feel like no matter what combination of paths I try, I get the error - or else flash just adds its own blank document class and nothing happens.我觉得无论我尝试哪种路径组合,我都会收到错误 - 否则 flash 只是添加了自己的空白文档 class 并且没有任何反应。 Thanks for the help.谢谢您的帮助。

Try setting your document class to 'examples.FLARManagerTutorial_2D'.尝试将您的文档 class 设置为“examples.FLARManagerTutorial_2D”。

Package names are really just a reflection of a file structure. Package 名称实际上只是文件结构的反映。 consider:考虑:

fla
src/ 
   com/
       mheavers/
                app/
                    FLARManagerTutorial_2D.as

The src folder contains the folders com/mheavers/app, which contains your class. src 文件夹包含文件夹 com/mheavers/app,其中包含您的 class。 This package would then be com.mheavers.app .然后这个 package 将是com.mheavers.app Set the filepath in your fla to src (the parent folder of your package/folder structure), and your document class to com.mheavers.app.FLARManagerTutorial_2D .将 fla 中的文件路径设置为 src (包/文件夹结构的父文件夹),将文档 class 设置为com.mheavers.app.FLARManagerTutorial_2D

In your case, make sure a folder called examples (that contains your.AS file) exists in your src folder if you wish that to be your package, assign the path to src, and set the doc class to examples.FLARManagerTutorial_2D .在您的情况下,如果您希望将 src 文件夹用作 package,请确保在您的src文件夹中存在一个名为examples (包含您的.AS 文件)的文件夹,将路径分配给 src,并将文档 class 设置为examples.FLARManagerTutorial_2D

I definitely had to monkey around with that a bit when I was just getting started with as3.当我刚开始使用 as3 时,我肯定不得不考虑一下。 Hope that helps.希望有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM