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

Go To StackoverFlow.com

1

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;
                }

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();

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 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.

2012-04-05 16:48
by Adzi


5

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.

2012-04-05 16:55
by Daniel
Helicopter is a varible of type Class - www0z0k 2012-04-05 17:00
what's the name of the class - Daniel 2012-04-05 17:02
Here is the Game.as code: http://pastebin.com/Wh1DfRN - Adzi 2012-04-05 17:07
http://pastebin.com/AYT2v6Ha for Helicopter.a - Adzi 2012-04-05 17:08
it should be _helicopter.x and y the - Ronnie 2012-04-05 17:08
the variable is not defined anywhere, and the class is not instantiate - Daniel 2012-04-05 17:11
OMFG IT WORKED> RONNIE DANIEL< THANK YOU FOR YOUR HELP BOTH!!!! U GUYS R AWESOME - Adzi 2012-04-05 17:11
mark the post as your answer so daniel gets some points : - Ronnie 2012-04-05 19:04
Ads