Ok, here we go again, AS3 and Singletons have been discussed almost as much as Peak Oil, but never-the-less, allow me to present yet another Singleton implementation, wrapped up in a neat little FDT template.
package ${enclosing_package} {
/**
* @author ${user}
*/
public class ${enclosing_type} {
private static var _instance : ${enclosing_type};
private static function hidden() : void {}
public static function getInstance() : ${enclosing_type} {
if( _instance == null ) {
_instance =
new ${enclosing_type}(hidden);
}
return _instance;
}
public function ${enclosing_type} (h:Function) {
if (h !== hidden) {
throw new Error( "${enclosing_type} and can only be accessed through ${enclosing_type}.getInstance()" );
}
}
${cursor}
}
}
Download the FDT template XML
August 12th, 2008
All the kids are debugging with Flash Debug Player these days, (haven't you heard?)
For those of you that don't know, the Debug version of the player sends trace commands to a text file which you can watch with a variety of tools, but we'll get into that later.
To get the Debug Player visit http://www.adobe.com/support/flashplayer/downloads.html and get the latest Netscape (Firefox) and ActiveX debug players.
With the latest upgrade of Flash Debug Player (9,0,28,0) there's been a few changes to accomodate the wonderful(?) Microsoft Vista, Which imposes certain security restrictions. Please note: this post only relates to Windows.
Adobe have provided documentation for the debug player, and for most people it'll work just fine, however, if you're in a corporate environment no doubt you have a roaming profile and this is where the fun begins.
Previously the environment variables %HOMEDRIVE% and %HOMEPATH% were used by the debug player to find it's settings file mm.cfg. It appears that this is no longer the case (the Adobe livedocs page doesn't tell you this.)
It seems that %USERPROFILE% is now used to determine the location of mm.cfg which will allow you to set the config of Flash Debug Player.
The rest of the information in this LiveDocs page is fine. I'll save you the trip over and give you the rest of the infor. The new fixed location of the Player log file is: %USERPROFILE%\Application Data\Macromedia\Flash Player\Logs\flashlog.txt and within the mm.cfg the settings now available are...
|
Property
|
Description
|
ErrorReportingEnable
|
Enables the logging of error messages.
Set the ErrorReportingEnable property to 1 to enable the debugger version of Flash Player to write error messages to the log file. To disable logging of error messages, set the ErrorReportingEnable property to 0.
The default value is 0.
|
MaxWarnings
|
Sets the number of warnings to log before stopping.
The default value of the MaxWarnings property is 100. After 100 messages, the debugger version of Flash Player writes a message to the file stating that further error messages will be suppressed.
Set the MaxWarnings property to override the default message limit. For example, you can set it to 500 to capture 500 error messages.
Set the MaxWarnings property to 0 to remove the limit so that all error messages are recorded.
|
TraceOutputFileEnable
|
Enables trace logging.
Set TraceOutputFileEnable to 1 to enable the debugger version of Flash Player to write trace messages to the log file. Disable trace logging by setting the TraceOutputFileEnable property to 0.
The default value is 0.
|
As far as setting up your mm.cfg file goes, it's a simple text file.
Using notepad enter the following lines
ErrorReportingEnable=0
TraceOutputFileEnable=1
Then save as the file to %USERPROFILE%/mm.cfg
If everything is working ok you will be able to read trace messages from Flash in the file %USERPROFILE%\Application Data\Macromedia\Flash Player\Logs\flashlog.txt
Log viewers...
There are a number of tools out there to view log files, and there are some which specifically target the Flash Debug Player, however due to the latest changes, many of these no longer work properly...
FlashTracer by Alessandro Crugnola (of SEPY fame) is a FireFox extension which will follow flashlog.txt output. You can get it here
A nice alternative is Log Viewer from BrineSoft a bog standard windows based file watcher.
Of course for the truly hardcore there's the unix tail command, available to windows users via the Cygwin project. If you want to play with that one, it's for command line veterans only.
Hopefully now you can stop mucking about with these XMLSocket or LocalConnection solutions, (or heaven forbid TextField.. I ask you!)
February 1st, 2007