# Explain this 'Error #1034' in my 'for each' loop

**URL:** <https://forum.kirupa.com/t/explain-this-error-1034-in-my-for-each-loop/305539>\
**Category:** flash\
**Created:** [February 26, 2010, 9:23pm UTC](https://forum.kirupa.com/t/explain-this-error-1034-in-my-for-each-loop/305539 "2010-02-26T21:23:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jrjellybeans](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@jrjellybeans](https://forum.kirupa.com/u/jrjellybeans)\
**Post date:** [February 26, 2010, 9:23pm UTC](https://forum.kirupa.com/t/explain-this-error-1034-in-my-for-each-loop/305539/1 "2010-02-26T21:23:39Z")

</div>

Hey all,

I’m getting a “error #1304: Type Coercion failed” error when I try to run the following code:

```auto

public class BattleController extends MovieClip {
        public var god:God;
        public var conRoomToKill:ConRoom;
        public var player0:PlayerBattle;
        public var player1:PlayerBattle;
        public var player2:PlayerBattle;
        public var arObject:Array;

        
        public function BattleController(vC:RoomController) {
            var i:int;
            conRoomToKill=vC;
            god=vC.god;
            
            arObject = new Array();
            
            createRoomObjects();
        }

public function createRoomObjects():void {
            player0 = new PlayerBattle(this,0);
            addChild(player0);
            
            player1 = new PlayerBattle(this,1);
            addChild(player1);
            
            player2 = new PlayerBattle(this,2);
            addChild(player2);
            
            arObject.push(player0);
            arObject.push(player1);
            arObject.push(player2);
            
            for each (var vO:PlayerBattle in arObject) {
                   vO.mHealth+=10;
            }
        }

```

The error seems to be in the “var vO: PlayerBattle” section. I thought that this was good code, but obviously it ain’t or my understanding of how things work is wrong.

So, based on the information I’ve read, it seems like vO: PlayerBattle is not the right data type in arObject. But, how could that be?

Any help or a point in the right direction would be really appreciated!
