<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CraigSimpson.net &#187; Flex</title>
	<atom:link href="http://craigsimpson.net/category/flex/feed/" rel="self" type="application/rss+xml" />
	<link>http://craigsimpson.net</link>
	<description>Flash &#38; Flex Development</description>
	<lastBuildDate>Thu, 30 Apr 2009 01:47:41 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>utility.Debugger</title>
		<link>http://craigsimpson.net/2009/01/utilitydebugger/</link>
		<comments>http://craigsimpson.net/2009/01/utilitydebugger/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 14:00:24 +0000</pubDate>
		<dc:creator>Craig</dc:creator>
				<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[My Work]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[debugging]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://craigsimpson.net/?p=85</guid>
		<description><![CDATA[
Description:
A Flex application that I developed to print trace messages to a custom debugger panel.  I use it in all my projects since trace does not work on applications running out side the Flash&#8217;s IDE.  Some of the features include 3 message levels so that you can choose not to get flooded with debugging messages. [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.craigsimpson.net/debugger.html" onclick=""><img class="size-medium wp-image-217" title="Debugger v1" src="http://craigsimpson.net/wp-content/uploads/2009/01/debugger_preview-300x247.jpg" alt="Screen Shot of Debugger" width="300" height="247" align="left" padding="10" /></a></p>
<h3>Description:</h3>
<p>A Flex application that I developed to print trace messages to a custom debugger panel.  I use it in all my projects since trace does not work on applications running out side the Flash&#8217;s IDE.  Some of the features include 3 message levels so that you can choose not to get flooded with debugging messages.  Secondly you can also highlight messages. This works great for error messages and looking for those hard to find variables.    Even if your compiling in Flash&#8217;s IDE, Debugger still sends out your message as trace. This is a life saver in time and debugging when your clients call say the live app is not working. This app is a must for any Flex or Flash project.</p>
<p><a title="Debugger Panel" href="http://craigsimpson.net/debugger.html" onclick="" target="_blank">[ View  debugger panel ]</a><br />
<br/></p>
<h3>Download:</h3>
<p><a title="Debugger.zip" href="http://craigsimpson.net/download/Debugger.zip" onclick="javascript:pageTracker._trackPageview('/downloads/download/Debugger.zip');">[ Debugger.zip 281 K ]</a> The source files for both the output panel and the static class that you place into your project to send messages to the panel. Instructions on using debugger panel is in the class file.<br />
<br/></p>

<div class="wp_codebox_msgheader wp_codebox_hide"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left2">Download <a href="http://craigsimpson.net/wp-content/plugins/wp-codebox/wp-codebox.php?p=85&amp;download=Debugger.as">Debugger.as</a></span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p852"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
</pre></td><td class="code" id="p85code2"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #3f5fbf;">/*
 Copyright(c) 2008-09 Craig Simpson, Some rights reserved.
 Your reuse is governed by the Creative Commons Attribution 3.0 United States License
*/</span>
 <span style="color: #9900cc; font-weight: bold;">package</span> net.craigsimpson.utility<span style="color: #000000;">&#123;</span>
&nbsp;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.net</span>.<span style="color: #004993;">LocalConnection</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">SecurityErrorEvent</span>;
	<span style="color: #0033ff; font-weight: bold;">import</span> <span style="color: #004993;">flash.events</span>.<span style="color: #004993;">StatusEvent</span>;
&nbsp;
	<span style="color: #3f5fbf;">/*
	 	Debugger Singleton Class:
&nbsp;
		Developed to be used in AS3 Flash &amp; Flex applications. The class sends debug meessages 
		to the custom built debugger panel. Kind of like looking trace commands in a browser. 
		Great for both development and when application is live on the web.
&nbsp;
			//Example actionscript to send messages to plane;
			var debugger:Debugger = Debugger.instance;
			debugger.connect(&quot;MyCoolApp&quot;);
			debugger.send(&quot;Test 1...2....3&quot;);
&nbsp;
		Debugger Panel Application:
&nbsp;
		The custom debugging panel source can be downloaded at www.craigsimpson.net/download/Debugger.zip
		Also a live version is hosted on my site at www.craigsimpson.net/debugger.html
&nbsp;
		Contact:
&nbsp;
		Report any bugs, comments, or suggestions at www.craigsimpson.net/contact
	 */</span>
&nbsp;
	dynamic <span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #9900cc; font-weight: bold;">class</span> Debugger
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> const CONNECTION_NAME<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #990000;">&quot;_debugger&quot;</span>;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> debuggerLC<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">LocalConnection</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _appName<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #6699cc; font-weight: bold;">var</span> _domain<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span>;
&nbsp;
        <span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> __instance<span style="color: #000000; font-weight: bold;">:</span>Debugger;
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> Debugger<span style="color: #000000;">&#40;</span>enforcer<span style="color: #000000; font-weight: bold;">:</span>SingletonEnforcer<span style="color: #000000;">&#41;</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #009900;">//Constructor</span>
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #0033ff; font-weight: bold;">get</span> instance <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span>Debugger
		<span style="color: #000000;">&#123;</span>
			<span style="color: #0033ff; font-weight: bold;">if</span><span style="color: #000000;">&#40;</span>Debugger.__instance == <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span>
				Debugger.__instance = <span style="color: #0033ff; font-weight: bold;">new</span> Debugger<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">new</span> SingletonEnforcer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #000000;">&#125;</span>
			<span style="color: #0033ff; font-weight: bold;">return</span> Debugger.__instance;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
			Send messages to output in the debugger window
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">message</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span>, <span style="color: #004993;">level</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">0</span>, hightlight<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span> = <span style="color: #0033ff; font-weight: bold;">false</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			debuggerLC.<span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span> CONNECTION_NAME, <span style="color: #990000;">&quot;outputText&quot;</span>, <span style="color: #004993;">message</span>, <span style="color: #004993;">level</span>, hightlight <span style="color: #000000;">&#41;</span>;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">message</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
			Connects application to debugger panel, must be called once in your application.  Since multiple apps are allowed to connected to the debugger
			panel applicationName helps indenifty which apps are currently connected.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> <span style="color: #004993;">connect</span><span style="color: #000000;">&#40;</span>applicationName<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span>, <span style="color: #004993;">domain</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">String</span> = <span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			_appName = applicationName <span style="color: #000000; font-weight: bold;">?</span> applicationName <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;Unknown Application&quot;</span>;
			_domain = <span style="color: #004993;">domain</span> <span style="color: #000000; font-weight: bold;">?</span> <span style="color: #004993;">domain</span> <span style="color: #000000; font-weight: bold;">:</span> <span style="color: #990000;">&quot;*&quot;</span>;
&nbsp;
			debuggerLC = <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">LocalConnection</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
			debuggerLC.<span style="color: #004993;">allowDomain</span><span style="color: #000000;">&#40;</span>_domain<span style="color: #000000;">&#41;</span>;
			debuggerLC.<span style="color: #004993;">addEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">SecurityErrorEvent</span>.<span style="color: #004993;">SECURITY_ERROR</span>, onConnectionError<span style="color: #000000;">&#41;</span>;
&nbsp;
			<span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span> _appName <span style="color: #000000; font-weight: bold;">+</span> <span style="color: #990000;">&quot; Connected &quot;</span>, <span style="color: #000000; font-weight:bold;">1</span>, <span style="color: #0033ff; font-weight: bold;">false</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
			Sends a message that is highlighted in red, for sending error messages that need to catch the endusers atttention.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> sendError<span style="color: #000000;">&#40;</span>errorMessage<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span> errorMessage, <span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #0033ff; font-weight: bold;">true</span> <span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
			Sends highlighted message to panel.
		*/</span>
		<span style="color: #0033ff; font-weight: bold;">public</span> <span style="color: #339966; font-weight: bold;">function</span> sendHighlighted<span style="color: #000000;">&#40;</span><span style="color: #004993;">message</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Object</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
		<span style="color: #000000;">&#123;</span>
			<span style="color: #004993;">send</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">message</span>, <span style="color: #000000; font-weight:bold;">2</span>, <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
&nbsp;
		<span style="color: #3f5fbf;">/*
		 *  Event Listeners
		 */</span>
		<span style="color: #0033ff; font-weight: bold;">private</span> <span style="color: #339966; font-weight: bold;">function</span> onConnectionError<span style="color: #000000;">&#40;</span>event<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">SecurityErrorEvent</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span> 
		<span style="color: #000000;">&#123;</span>
			debuggerLC.<span style="color: #004993;">removeEventListener</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">SecurityErrorEvent</span>.<span style="color: #004993;">SECURITY_ERROR</span>, onConnectionError<span style="color: #000000;">&#41;</span>;
			debuggerLC = <span style="color: #0033ff; font-weight: bold;">null</span>;
&nbsp;
			<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;LOCAL CONNECTION SECURITY ERROR!&quot;</span><span style="color: #000000;">&#41;</span>;
			<span style="color: #0033ff; font-weight: bold;">throw</span> <span style="color: #0033ff; font-weight: bold;">new</span> <span style="color: #004993;">Error</span><span style="color: #000000;">&#40;</span><span style="color: #990000;">&quot;onConnectionError: &quot;</span><span style="color: #000000; font-weight: bold;">+</span>event.<span style="color: #004993;">toString</span><span style="color: #000000;">&#41;</span>;
		<span style="color: #000000;">&#125;</span>
	<span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span>
&nbsp;
<span style="color: #0033ff; font-weight: bold;">internal</span> <span style="color: #9900cc; font-weight: bold;">class</span> SingletonEnforcer <span style="color: #000000;">&#123;</span><span style="color: #000000;">&#125;</span></pre></td></tr></table></div>

<p><br/></p>
<h2>Future:</h2>
<p>Documentation write up for implementation of Debugger class and using the panel. Any suggestions for future releases are greatly appreciated.</p>
]]></content:encoded>
			<wfw:commentRss>http://craigsimpson.net/2009/01/utilitydebugger/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
