1067年:一个Class类型的值隐式强制给无关联的类型flash.display一:的DisplayObject类型、隐式、Class、display

2023-09-09 21:50:47 作者:荒凉的午夜

因此​​,举例来说,我有三只名为.as文件Helicopter.as,Game.as,Blue.as 我也有一个名为Helicopter.fla(这些文件都假设链接在一起,使直升机游戏)一个FLA文件。在Game.as文件中,我有以下几点;

So for instance, I've got three .as files called 'Helicopter.as, Game.as, Blue.as' and I also have a .fla file called Helicopter.fla (These files are all suppose to link together, to make the helicopter game) . In the Game.as file, I have the following;

if (blue1.hitTestObject(Helicopter))

                {
                    trace("YOU HIT THE BLOCK!");

                    Helicopter.x = 76;
                    Helicopter.y = 217;
                }

我得出在不同的文件中使用这个code称为Helicopter.as使用API​​所谓的直升机^;

I have drawn the so called 'Helicopter'^ using API in a different file called Helicopter.as using this code;

        graphics.beginFill(0x00FF00);
        graphics.drawCircle(0, 60, 35);
        graphics.endFill();

不过,我本来的直升机符号在Helicopter.fla文件(我现在已经删除)绘制的,而现在,我已经得出的使用API​​直升机',我得到这个错误;

However, I originally had the "Helicopter' symbol drawn in the Helicopter.fla file (which I've now deleted), and now that I've drawn the 'Helicopter' using API, I get this error;

 ''1067: Implicit coercion of a value of type Class to an unrelated type flash.display:DisplayObject.''

Flash不承认原来的直升机符号(在Helicopter.fla文件,因为我删除了它)。但我想在系统检测到循环使用API​​绘制(在Helicopter.as文件)。我不知道怎么样怎么样名称的API绘制圆'直升机',因此我得到一个错误。那么,如何命名API圈'直升机',所以Game.as文件识别。如果你不知道我在说什么,那也不用担心,因为我不知道太多。谢谢。如果你愿意,我可以粘贴所有code我到目前为止已经完成。

Flash doesn't recognise the original Helicopter symbol (in the Helicopter.fla file, because I deleted it). But I want the system to detect the 'circle' drawn using API (In the Helicopter.as file). And I have no idea how to how to name the API drawn circle 'Helicopter', thus I'm getting an error. So how do I name the API circle to 'Helicopter', so the Game.as file recognises it. If you have no idea what I'm talking about, then don't worry, because I don't know too. Thank you. If you want, I can paste all the code I've done so far.

推荐答案

直升机是一个类不是一个变量,因此,你不能分配直升机。 X 。您需要创建一个变量 VAR直升机:直升机=新直升机(); 和使用 heli.x

Helicopter is a class not a variable, therefore you cannot assign Helicopter.x. You need to create a variable var heli:Helicopter = new Helicopter(); and use heli.x

这也可能是因为你不遵循编程标准,而直升机,其实是一个变量,而不是一类,虽然错误似乎表明并非如此。

it also could be that you're not following the programming standards, and Helicopter is in fact a variable and not a Class, though the error seems to indicate otherwise.