R – Trace what runs the function

actionscript-3flash

private function dataLevel():void {

        //Level 2
        a1=new Array(b1,b2);
        a2=new Array(b3,b4);


        //Level 1
        allA=new Array(a1,a2);


        //trace if the following level exist

        //if the following level exist, create the Branch
        if (allA is Array==true) {
            createBranch(this);

            if (allA[0] is Array==true) {
                createBranch(allA[0]);
            }

            if (allA[1] is Array==true) {
                createBranch(allA[1]);
            }
        }
    }


    private function createBranch(event:Object):void {

        trace(event.target);

}

Best Answer

Just naming a variable as event won't make it an Event object (and give it a target property). Use trace(event); to trace the passed parameter. Even better, change the variable name to arg1 (argument1) or something that makes more sense.

private function createBranch(arg1:Object):void 
{
    trace(arg1);
}

event is normally used for variables of type Event or its subclasses in an event handler.

Related Topic