# 1067 implicit coercion of a value of type Array

**URL:** <https://forum.kirupa.com/t/1067-implicit-coercion-of-a-value-of-type-array/329556>\
**Category:** flash\
**Created:** [September 13, 2012, 11:03pm UTC](https://forum.kirupa.com/t/1067-implicit-coercion-of-a-value-of-type-array/329556 "2012-09-13T23:03:17Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![hq231](https://avatars.discourse-cdn.com/v4/letter/h/d26b3c/32.png) [@hq231](https://forum.kirupa.com/u/hq231)\
**Post date:** [September 13, 2012, 11:03pm UTC](https://forum.kirupa.com/t/1067-implicit-coercion-of-a-value-of-type-array/329556/1 "2012-09-13T23:03:17Z")

</div>

This error keeps appearing:

“1067 implicit coercion of a value of type Array to an unrelated type flash.display.DisplayObject”

When I added code to test for hits between the array “ships” and the movieclip “city1”

the error is originating from my document class line 128:  
if (city1.hitTestObject(ships))

any help will be greatly appreciated thanks in advance  
code:  
package  
{

```
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Mouse;

public class Level extends MovieClip
{

    var ships:Array;
    var bullets:Array;
    public var avatar:Avatar;
    private var score:Number;
    public var cash:Number;
    public var city1:City1;
    var health:int;

    public function Level()
    {

        health:10;

        avatar = new Avatar();
        addChild( avatar );

        avatar.x = mouseX;
        avatar.y = mouseY;

        score = 0;
        cash = 0;

        //addEventListener(Event.ENTER_FRAME, loop);
        ships = new Array ;
        bullets = new Array ;

        addEventListener(Event.ENTER_FRAME, update);

    }

    function update(e:Event)
    {
        avatar.x = mouseX;
        avatar.y = mouseY;
        Mouse.hide();

        output.text = "Score: " + score;
        output2.text = "Cash: $ " + cash;

        

        if (numChildren&lt;10)
        {

            var s = new Ship();

            addChild(s);

            s.x = Math.random() * stage.stageWidth;
            s.y = -120;
            //s.rotation = Math.random() * 360;
            ships.push(s);

        }

        for (var b = ships.length - 1; b &gt;= 0; b--)
        {
            ships**.update();
            if (ships **.x &lt; 0 || ships**.x &gt; 500 || ships**.y &gt; 500)
            {
                this.removeChild(ships**);
                ships.splice(b, 1);
            }

            for (var i = bullets.length - 1; i &gt;= 0; i--)
            {
                bullets*.update();
                if (bullets*.parent == null)
                {
                    bullets.splice(i, 1);
                    i--;
                }
            }

            for (var count = 0; count&lt;ships.length; count++)
            {
                ships[count].update();
                for (i=0; i&lt;bullets.length; i++)
                {
                    if (ships[count].hitTestObject(bullets*))
                    {
                        if (ships[count].x &lt; -50 || ships[count].x &gt; 550 || ships[count].y &gt; 700)
                        {if (ships!=null)
        {
            if (city1.hitTestObject(ships))
            {
                trace("hit");
            

                            removeChild(ships[count]);
                            ships.splice(count, 1);

```

}  
}  
}

```
                        removeChild(bullets*);
                        bullets.splice(i,1);
                        removeChild(ships[count]);
                        ships.splice(count, 1);

                        //trace(score);
                        score += 10;//*level;
                        //trace(score);
                        cash += 5;//*level;

                        //if (ships[count].hitTestObject(turret))
                        //{
                        //
                        //
                        //removeChild(ships[count]);
                        //ships.splice(count, 1);
                        //
                        //
                        //}

                    }

                }

            }
        }
    }
}

```

}
