AS3 将类导入到主时间线
你好,我有一个 android 项目正在进行,我想导入一个动作脚本类以在主时间轴中使用。我编写了该类并导入了它,但出现以下错误:
第 1 行 5001:包“com”的名称未反映此文件的位置。请更改此文件中的包定义名称,或移动该文件。
这是来自时间线
import com.networkScores;
var network:networkScores = new networkScores();
addChild(network);
trace(network.arr[0]);
这是来自类文件
package com
{
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
public class networkScores extends MovieClip
{
public function networkScores()
{
}
}
}
有人知道我在这里做错了什么吗?
Hello I have a air for android project going and I am wanting to import a actionscript class for use in the main timeline. I wrote the class and imported it, but I get the following errors:
Line 1 5001: The name of package 'com' does not reflect the location of this file. Please change the package definition's name inside this file, or move the file.
Here is from the timeline
import com.networkScores;
var network:networkScores = new networkScores();
addChild(network);
trace(network.arr[0]);
Here is from the class file
package com
{
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.display.MovieClip;
public class networkScores extends MovieClip
{
public function networkScores()
{
}
}
}
Anyone have any idea what i am doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
确保将 .as 类文件保存在 com 文件夹中,因为名称空间本质上是文件夹结构。然后确保类路径指向正确的位置。
例如,“
c:/as3dev/projectname/com/networkScores.as
”,您可以添加“c:/as3dev/projectname/
”的类路径。当然,如果您还没有这样做,那么当然可以在您的项目属性中将 class 设置为 com.networkScores。Make sure to have your .as class file saved in the com folder as name spaces are essentially folder structures. Then ensure class path is pointing to the right place.
For example, "
c:/as3dev/projectname/com/networkScores.as
" , you can add a class path of "c:/as3dev/projectname/
". Then of course in your project properties set class to com.networkScores, if you have not yet done so.我猜你的类位于错误的目录、文件夹中。包名称本质上定义了类如何在源目录之间分布。这样做是为了确保各种相同命名的类的兼容性。我猜,您将该
networkScores
类放在主应用程序所在的同一目录中。在这种情况下,您应该将包定义重命名为空,如下所示:或者,您应该将
networkScores
类放入项目主目录中名为“com”的目录/文件夹中。您可以在此处了解有关软件包的更多信息。
I'm guessing your class is in the wrong directory, folder. Package names, essentially define how classes are distributed between your source directories. This is done to ensure various, same named classes compatibility. I'm guessing, you're putting that
networkScores
class in the same directory that your main application is in. In that case, you should rename the package definition to be empty, like this:Or, you should put the
networkScores
class into a "com" named directory / folder in your project's main directory.You can read more about packages here.
可能存在不需要的项目路径,我也遇到了同样的问题。
我只是将我的框架复制粘贴到一个新文件中,它就起作用了。
There may be unwanted project path, I had same problem.
I just copy pasted my frames to a new file and it worked.