Avg. Rating 5.0

Problem

You can see trace statements in the output window within Flash. You can also use a debugger for this however what if you can't install them or have no access to get them?

Solution

Here's an option... tracing on stage. Create a text field and trace to the stage. I hope this is a good alternative to people who wouldn't want to install anything else.

Detailed explanation

I may place this on the stage in an area that doesn't interfere with the movie just to make sure the functions are being called.

I called the movieClip traceField.

within my function along with my trace statement:

trace("Tracing init function)";

I also add

traceField.text = "Tracing init function to stage";

That's it. Seems to make my workflow easier.

stop();
init();
function init():void{
        //Call trace statements
        trace ("Init function has been called");
        traceField.text = "Init function has been called";

        var cbtn:MovieClip = new clickbtn();
        cbtn.x = 140;
        cbtn.y = 140;
        addChild(cbtn);
        cbtn.buttonMode = true;
        cbtn.addEventListener(MouseEvent.CLICK, btnClick);
        cbtn.addEventListener(MouseEvent.ROLL_OVER, btnRollOver);
        cbtn.addEventListener(MouseEvent.ROLL_OUT, btnRollOut);
}
function btnClick(e:MouseEvent):void{
        
        //Call trace statements
        trace("Button has been Clicked");
        traceField.text = "Button has been Clicked";
        
}

function btnRollOver(e:MouseEvent):void{
       //Call trace statements
        trace("Button rolled over");
        traceField.text = "Button rolled over";
        
}

function btnRollOut(e:MouseEvent):void{
       //Call trace statements
        trace("Button rolled out");
        traceField.text = "Button rolled out";
        
}


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes