Great little debuging snippet found while browsing. The code adds different coloured borders to the assets depending on its level. Leave commented out if not needed.
1
2
3
4
5
6
7
8
| * { outline: 2px dotted red }
* * { outline: 2px dotted green }
* * * { outline: 2px dotted orange }
* * * * { outline: 2px dotted blue }
* * * * * { outline: 1px solid red }
* * * * * * { outline: 1px solid green }
* * * * * * * { outline: 1px solid orange }
* * * * * * * * { outline: 1px solid blue } |
CSS, Programming CSS, debug, html
It may be interesting to know at runtime whether an application is running from a debug or release SWF file. It allows the application to automatically execute debug specific code when the file is a debug SWF file and ignore this code when it is published as a release file. Also, it should be nice to know if you have a debug flash player just for the same reasons. But for the last one, there is a function in the Capabilities class called isDebugger.
One solution would be to use conditional compilation. The other solution is in the following code (hack).
package org.adm.runtime
{
import flash.system.Capabilities;
public class ModeCheck
{
/**
* Returns true if the user is running the app on a Debug Flash Player.
* Uses the Capabilities class
**/
public static function isDebugPlayer() : Boolean
{
return Capabilities.isDebugger;
}
/**
* Returns true if the swf is built in debug mode
**/
public static function isDebugBuild() : Boolean
{
return new Error().getStackTrace().search(/:[0-9]+]$/m) > -1;
}
/**
* Returns true if the swf is built in release mode
**/
public static function isReleaseBuild() : Boolean
{
return !isDebugBuild();
}
}
}
This code simply searches for line numbers of errors in StackTrace result. Only StackTrace result of a debug SWF file contains line numbers. Then we know that we are running a debug or release SWF file.
This class is also available in the Components Pack at Runtime subpackage
Flex / ActionScript, Programming actionscript, as3, debug, flex, release