trace() is a normal function. If you pass arguments to trace(), they will be evaluated first.

1. trace (name == "Jens");
Wouldn't you here expect a true or false depending on your name?

2. Write a custom function to which you pass setMovieClipX(movieClip,286). What parameter type you would use?

function testUpdate(updated : Boolean) : void {
        trace ("updated", updated);
}
testUpdate(setMovieClipX(movieClip,286));

In this case it seems to be clear that the mc is positioned first.

3. I cannot count how many times I have tried to find a bug due to this trace(expression) issue. While in DEBUG mode everything worked well, the production version did not work :-) It is really a danger that should be in mind.

Jens

Am 02.02.2011 11:12, schrieb Wenzler, Thomas:
Hi List, I just made a little experiment with this code...

function setMovieClipX(mc,desiredCoordX):Boolean
{
        var updated:Boolean=true;
        (desiredCoordX!=mc.x)?mc.x=desiredCoordX:updated=false;
        return updated;
}
trace(setMovieClipX(movieClip,286));

...and found to my utmost surprise that the trace command actually executed the 
function and updated the movieClip.x position instead of just tracing true or 
false.
If you check omit Trace in the Publish settings, movieClip remains at it's x 
Position.

Wonder if this could be of any use or is a potential danger when using traces 
to debug?

Regards
Thomas
_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders


_______________________________________________
Flashcoders mailing list
Flashcoders@chattyfig.figleaf.com
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to