19 Replies Latest reply on Apr 10, 2017 7:44 AM by brendenc14282108

    I need help trying to write my code to find object inside another object.

    brendenc14282108

      I am using AS3 in Flash Professional CS5.5

       

      i get these errors when I put my "boxMC" into the background of "WorldMC". it works not how i want it when i put put boxMC on my main stage. When i do so it only traces for that one boxMC not the ones that are spawning inside of WorldMC.

      Here are my errors:

      1067: Implicit coercion of a value of type Array to an unrelated type tankscript.turrent:Box.

      1180: Call to a possibly undefined method Box.

      1061: Call to a possibly undefined method push through a reference with static type tankscript.turrent:Box

      1119: Access of possibly undefined property length through a reference with static type tankscript.turrent:Box.

      Here is my code that is having the issues.

       

        var boxMC:Array;

        WorldMC.boxMC = new Array();

       

        //------------------------------

        // -----Box Spawning------

        //------------------------------

        //only spawn a box if there are less tan 100 already on screen

        if(WorldMC.numChildren<10)

        {

        // Make a new instance of the box class

        var bx = new Box();

        // add the box to the display list

        WorldMC.addChild(bx);

        //position and rotate the Box;

        bx.x = Math.random() * -1100;

        bx.y = Math.random() * 1;

        bx.rotation = 40;

        // add the box to list of box

        WorldMC.boxMC.push(bx);

        //trace the length of the array

        trace(WorldMC.boxMC.length);