QUstudent
QUstudent

Reputation: 5

Using addChild error with coercion

I'm attempting to use the addChild function in a game to have random objects appear and then move down a river to hit a controllable boat. I've watched several tutorials on youtube and think that I'm following the instructions properly but I'm getting the error #1067

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

I've set the barrel's class to barrel, and set to export the movie clip, what am I missing here?

{
    var bar:barrel = new barrel();
    addChild(barrel);
    bar.x = 200;
    bar.y = 200;
}

Upvotes: 0

Views: 85

Answers (1)

Karmacon
Karmacon

Reputation: 3190

bar is the instance, barrel is the class. Change addChild(barrel) to addChild(bar);

var bar:barrel = new barrel();
addChild(bar);
bar.x = 200;
bar.y = 200;

Upvotes: 2

Related Questions