jeudi 30 mars 2017

How to getChildAt a movie clip inside a movieclip?

I have a movie clip linkage named "trainglePoint" inside a movieclip with a "bgdemo" instance and I was wondering how will I get the "trianglePoint" to work.

also "gags" is the character that will get the "trianglePoint"

this is my code below, which doesn't work.

thanks!

edit: forgot to add that the 'trianglePoint' is put onto stage multiple times (dont know if that helps)

var pickUpsArray:Array = new Array();

stage.addEventListener (Event.ENTER_FRAME, pickUpItems);

public function pickUpItems (e:Event)
    {
            for (var i=0; i<numChildren;i++)
    {
        if (getChildAt(i) is bgdemo.trianglePoint)
        {
            pickUpsArray.push(getChildAt(i));
        }
    }

        for (var j=0; j<pickUpsArray.length;j++)
        {
            if (gags.hitTestObject (pickUpsArray[j]))
            {
                removeChild(pickUpsArray[j]);
                trace ("hitTestObject: YES");
            }
        }
    }

Aucun commentaire:

Enregistrer un commentaire