Eli Atlas

Enabling Flash debug player in google Chrome

Posted in Uncategorized by eli on August 2nd, 2011

Every time I update my Flash player in Chrome, or need to switch to debug version I get stuck. I keep on forgetting how to do it, and find myself googling for it.

So I figured, why not to put it on my blog, easiest place to find it :)

Future me, here you go:

* Navigate to chrome://plugins/ in Chrome

* Press “”+Details” on the right

* Find Flash and disable the version you’ve got

* Enable the other version

* Call Mom, she misses you

Cheers!

 

HTML5 and Flash post on rounds tech blog

Posted in Uncategorized by eli on June 28th, 2011

Just posted a new article on rounds tech blog. HTML5 vs Flash thing never gets old :)

Check it out here

AS3 flash.trace.Trace Hidden Class

Posted in ActionScript,Flash,Uncategorized by eli on February 27th, 2011

Yep, there is a Trace() class. Actually it is  flash.trace.Trace class to be more specific.

Found it here (Russian).

It is not documented, but really cool. It exists since Flash Player 9.0.45, if I’m not mistaken, and it is used in FlashBuilder profiler. So what it does you ask? I”ll tell you what it does… It allows trace all the function which are being fired in your SWF.  And the arguments of the functions. And the lines of the functions if you want. Since there is no documentation for it, the only way to find out is to look in tamarin sources. I found this link on some adobe’s forum:

http://hg.mozilla.org/tamarin-central/file/e774dfe22b39/extensions/Trace.as

Here are the methods of the class:

setLevel(l:int, target:int=LISTENER)

First argument is level, second is target. Level can be one of the following:


METHODS:int = 1;					// method entry only
METHODS_WITH_ARGS:int = 2;				// method entry and arguments
METHODS_AND_LINES:int = 3;				// method entry and line numbers
METHODS_AND_LINES_WITH_ARGS:int = 4;	               // method entry, arguments and line numbers

and target can be FILE or LISTENER. Use FILE if you want to see regular traces in log file. Use LISTENER for your own function.

setListener(f:Function)

With this method you will be able to set the listener for all the traces. Listener function should be able to receive 4 parameters:

private function traceListener(fileInfo:String,lineNumber:String,classAndMethod:String,methodArguments:String):void

And here you go, example code:

import flash.trace.Trace;
import flash.text.TextField;

var outputField:TextField = new TextField();

outputField.width = outputField.height = 300;
outputField.multiline = true;
addChild(outputField);

Trace.setLevel(Trace.METHODS_AND_LINES_WITH_ARGS, Trace.LISTENER);
Trace.setListener(traceListener);

function traceListener(  fileInfo:String,  lineNumber:String,  classAndMethod:String,  methodArguments:String):void
{
	outputField.appendText("-" + classAndMethod + " " + methodArguments + "\n");
}

function initTrace(arg1:String, arg2:String):String
{
	return arg1 + " " + arg2;
}

initTrace("a", "b");
stop();

And here is the result:

If you don’t see anything, means you don’t have Flash Debug version installed. Get it here

As far as I can see, this class may be really handy sometimes. It can get little annoying if you have some ENTER_FRAME listeners or intervals, but you can easily overcome it with custom traceListener()

By the way …

There is another way to trace all functions in runtime, and it is changing your mm.cfg AS3Trace property. But although mm.cfg is much more powerful in other aspects, the Trace class is much more useful for traces in most cases I would think off. All the stuff about mm.cfg you can read here:

http://jpauclair.net/2010/02/10/mmcfg-treasure/

Good luck tracing!