编译器错误,这让我在ActionScript混淆 [英] A compiler error that makes me be confused in ActionScript

查看:172
本文介绍了编译器错误,这让我在ActionScript混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,这是我想说明的是我不熟悉的动作, 所以不要怪我了很多的一些基本的错误。 我刚刚得知它只有很短的时间。因此,脚本访问ActionScript的一些技巧总是AP preciated。 :)

Firstly, something I want to explain is I am not familiar with ActionScript, so don't blame me a lot for some basic mistakes. I have just learned it for a short time only. Thus, a few tips of scripting ActionScript is always appreciated. :)

我不知道为什么编译器说 我的一个类的构造函数不接受任何参数。

I don't know why the compiler said the constructor of one of my classes doesn't accept any parameter.

确定。你可以通过如下所示code拿到了我的意思。

OK. You might get my meaning through code shown below.

下面一个Player.as:

Here a Player.as:

public class Player extends Sprite
{
    public var mcHealthBar:HealthBar;
    public function Player()
    {
        // Here a compiler error is found.
        mcHealthBar = new HealthBar(max_health);
    }
}

和还HealthBar.as:

and also a HealthBar.as:

public class HealthBar extends MovieClip
{
    private var max_hp:int;

    public function HealthBar(MaxHP:int)
    {
        // constructor code
        max_hp = MaxHP;
    }
}

编译器说HealthBar的构造函数不能带参数使用, 但你可以清楚地看到HealthBar()构造HealthBar.as里面已经写了参数MAXHP。

The compiler said HealthBar's constructor could not be used with arguments, but you can clearly see the HealthBar() constructor inside the HealthBar.as has already been written with a argument MaxHP.

最后,我要问的是,为什么编译器错误产生的?

Lastly, what i want to ask is, why the compiler error was produced?

注:我使用的Flash-Builder和Flash-专业一起编码。 我创建通过Flash-Builder中的Flash-Professional项目。 我画通过使用Flash的专业,我code。通过使用Flash-Builder中。

NOTE: I am coding by using Flash-Builder and Flash-Professional together. I created a Flash-Professional project through Flash-Builder. I draw by using Flash-Professional, and I code by using Flash-Builder.

可能有一些语法,错误的英文错误...... 所以,我很抱歉,我很糟糕的英语大声笑...

There may be some grammatically-wrong English mistakes... So I am very sorry for my very bad English lol...

推荐答案

这是通常当我以前就遇到这个问题的问题:

This is generally the problem when I've faced this issue before:

HealthBar 很可能绑在库对象中的的FlashPro 。 (你在导出的动作,并给予它的类名 HealthBar )。

HealthBar is likely tied to a library object in FlashPro. (you've exported it for actionscript and given it the class name HealthBar).

问题是,的FlashPro是不多见的类文件,因此它会产生它自己的(不具有构造函数参数)。

The issue is that FlashPro is not seeing the class file, so it generates it's own (which doesn't have the constructor argument).

您可以测试是否的FlashPro通过点击库对象的链接属性的编辑图标看到文件(见图片)。如果定制的。至于文件中出现,那么这是没有问题的。

You can test if flashPro sees the file by clicking the edit icon on the linkage properties of the library object (see image). If the custom made .as file comes up, then this is not the problem.

通常的原因是。至于文件是不是在正确的地方,或者包名是不正确的文件所在的物理生活。

Usually the cause is that the .as file is not in the right place, or the package name isn't right for where the file physically lives.

如果你的。如文件只使用包{,则默认情况下该文件应该放在相同的目录的.fla 文件。

If your .as file is just using package { , then by default the file should be placed in the same directory as the .fla file.

如果是包乙{那么它应该是在一个文件夹,名为鲍勃的(并且默认的文件夹将在同一目录下的.fla)

If was package bob { then it should be in a folder called bob (and the folder by default would be in the same directory as the .fla)

您可以更改其中的.fla通过去寻找类文件的动作设置可以在文件菜单上找到。

You can change where the .fla looks for class files by going to the ActionScript Settings which can be found on the file menu.

这窗口称为标签源路径,您可以添加目录查找.as文件。

That window has tab called Source Path where you can add directories to look for .as files.

这篇关于编译器错误,这让我在ActionScript混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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