<?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>rabidGadfly &#187; quickTip</title>
	<atom:link href="http://rabidgadfly.com/category/quicktip/feed/" rel="self" type="application/rss+xml" />
	<link>http://rabidgadfly.com</link>
	<description>Simple Solutions to Nagging Coding Problems</description>
	<lastBuildDate>Wed, 19 Oct 2011 13:43:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>ColdFusion Dynamic Argument Naming in Method Calls</title>
		<link>http://rabidgadfly.com/2008/02/coldfusion-dynamic-argument-naming-in-method-calls/</link>
		<comments>http://rabidgadfly.com/2008/02/coldfusion-dynamic-argument-naming-in-method-calls/#comments</comments>
		<pubDate>Tue, 26 Feb 2008 15:32:23 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[quickTip]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=60</guid>
		<description><![CDATA[I created a custom tag recently that required a method argument name be passed as an attribute. While I&#8217;m familiar with the usual techniques of using dynamic variable names, they didn&#8217;t work in this situation. Here&#8217;s what I was attempting to do: Main Page Custom Tag The idValue wasn&#8217;t an issue but the idColumn wouldn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>I created a custom tag recently that required a method argument name be passed as an attribute. While I&#8217;m familiar with the usual techniques of using dynamic variable names, they didn&#8217;t work in this situation.</p>
<p>Here&#8217;s what I was attempting to do:</p>
<p><strong>Main Page</strong></p>
<pre><code>

<cfmodule template="customtags/deleteRecord.cfm"
				idValue = "1"
				idColumn = "colName" />

</code></pre>
<p><strong>Custom Tag</strong></p>
<pre><code>

<cfset obj = createObject("component","com.mycomponent")>
<cfset qRecord = obj.getRecord(attributes.idColumn = attributes.idValue) />

</code></pre>
<p>The idValue wasn&#8217;t an issue but the idColumn wouldn&#8217;t work. I tried Evaluate and &#8220;#attributes.idColumn#&#8221; and a few other similar methods to no avail. Finally, I remembered that you can pass a structure as an argument collection. So I ended up creating a new structure and passing it like this:</p>
<pre><code>

<cfset methodParms = structnew() />
<cfset methodParms[attributes.idColumn] = attributes.idValue />
<cfset qRecord = obj.getRecord(argumentcollection = methodParms) />

</code></pre>
<p>And that finally worked.</p>
<p>If there&#8217;s another solution out there, please enlighten me.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/02/coldfusion-dynamic-argument-naming-in-method-calls/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>AS3 Simple Color Code Converter</title>
		<link>http://rabidgadfly.com/2008/02/as3-simple-color-code-converter/</link>
		<comments>http://rabidgadfly.com/2008/02/as3-simple-color-code-converter/#comments</comments>
		<pubDate>Fri, 08 Feb 2008 13:14:35 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[quickTip]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=57</guid>
		<description><![CDATA[I just finished writing my first AS3 application. Part of its functionality allowed a color code to be passed in as a variable. The problem I ran into was that the color code was being passed by web developers. Instead of &#8220;0xFFCC00&#8243; they would pass &#8220;#FFCC00&#8243;. Understandable mistake, but garbage to Flash, so the custom [...]]]></description>
			<content:encoded><![CDATA[<p>I just finished writing my first AS3 application. Part of its functionality allowed a color code to be passed in as a variable. The problem I ran into was that the color code was being passed by web developers. Instead of &#8220;0xFFCC00&#8243; they would pass &#8220;#FFCC00&#8243;. Understandable mistake, but garbage to Flash, so the custom color would never be applied.</p>
<p>Rather than require the RGB code to be passed in, I wrote a short function to check for the HTML Hex format and convert it if necessary. It uses a regular expression to delete any occurrence of &#8216;#&#8217; and it adds &#8220;0x&#8221; to the beginning of the color code if it doesn&#8217;t already exist.</p>
<p>To see how it works, paste the following code into a blank Flash document and preview it:</p>
<pre><code>
//Create a text field and populate it
var myTextField:TextField = new TextField();
myTextField.text = "Hello World";
addChild(myTextField);

//Convert incorrectly formatted color string
var passedColor:String = "#FFCC00";
var newColor:String = fixColorCode(passedColor);
trace(newColor); //0xFFCC00 will be returned

//change color
var newFormat:TextFormat = new TextFormat();
newFormat.color = newColor;
myTextField.setTextFormat(newFormat);

function fixColorCode($color:String) :String
{
   var submittedColor:String = $color;
   var validColor:String;
   var pattern:RegExp = /#/;

   submittedColor = $color.replace(pattern,"");

   pattern = /0x/;
   if (submittedColor.substring(0,2) != "0x") {
      validColor = "0x"+submittedColor;
   } else {
      validColor = submittedColor;
   }

   return validColor;

}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/02/as3-simple-color-code-converter/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Retrieving Records with Max Values using TOP</title>
		<link>http://rabidgadfly.com/2007/08/retrieving-records-with-max-values-using-top/</link>
		<comments>http://rabidgadfly.com/2007/08/retrieving-records-with-max-values-using-top/#comments</comments>
		<pubDate>Wed, 15 Aug 2007 14:46:08 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[quickTip]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=45</guid>
		<description><![CDATA[I know I know, it&#8217;s a horrible title. If anyone has a better suggestion please let me know! Here&#8217;s what I&#8217;m talking about: I have two tables; the first table contains unique records describing games and the second contains game ids, scores, and user ids. Game id is joining the first table to the second [...]]]></description>
			<content:encoded><![CDATA[<p>I know I know, it&#8217;s a horrible title. If anyone has a better suggestion please let me know!</p>
<p>Here&#8217;s what I&#8217;m talking about:</p>
<p>I have two tables; the first table contains unique records describing games and the second contains game ids, scores, and user ids. Game id is joining the first table to the second in a one to many, something like this:</p>
<p>Games<br />
======<br />
gameID<br />
gameName</p>
<p>GameScores<br />
=========<br />
gameID<br />
userID<br />
score</p>
<p>MY MISSION: Retrieve the user with the high score for each game in one query.</p>
<p>After much trial, error, and gnashing of teeth, the solution, as usual, proved to be ridiculously simple:</p>
<pre><code>
SELECT (select top 1 userID from GameScores where gameID = Games.gameID order by score desc) as topScoreUser,
                Games.gameName,Games.gameID, s.score
FROM Games
JOIN   GameScores s on s.gameID = Games.gameID
</code></pre>
<p>What this does is return one record for each game. Since I&#8217;m only returning the top record in the query and I&#8217;m ordering by score in descending order, I&#8217;m getting the top score and player for each game.</p>
<p>I&#8217;ve run into quite a few instances now where TOP has proved invaluable. Unfortunately it always seems to take me an hour of futzing around before I remember to use it!</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2007/08/retrieving-records-with-max-values-using-top/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to Get Flash AS2 to Display Italicized HTML Text</title>
		<link>http://rabidgadfly.com/2007/08/how-to-get-flash-as2-to-display-italicized-html-text/</link>
		<comments>http://rabidgadfly.com/2007/08/how-to-get-flash-as2-to-display-italicized-html-text/#comments</comments>
		<pubDate>Fri, 10 Aug 2007 15:09:12 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[quickTip]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=44</guid>
		<description><![CDATA[Wacky Flash quick tip #127: A co-worker of mine recently asked me how to get italics to appear in a Flash html Text Field. Use the i tag I told him but he said he tried that and the text disappeared altogether. Assuming he was deranged I quickly opened a new Flash document and attempted [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Wacky Flash quick tip #127:</strong></p>
<p>A co-worker of mine recently asked me how to get italics to appear in a Flash html Text Field. Use the i tag I told him but he said he tried that and the text disappeared altogether. Assuming he was deranged I quickly opened a new Flash document and attempted to demonstrate what I was talking about.</p>
<p>I created a dynamic text field, marked it as html, embedded my font, gave it an instance name, wrote a little AS to populate it and hit CTRL-ENTER. To my surprise, there was no text on the stage. After retracing my steps to make sure I didn&#8217;t miss anything I tried again to make sure. Nope, still not working. It ended up taking me about 20 minutes to figure out.</p>
<p>Here&#8217;s the trick:<br />
You have to place a dynamic text field on the stage for each style of the font you want to use. For example, the string I&#8217;m using to populate the field is &#8220;<i>hello</i> there&#8221;, so I had to place one dynamic text field with the italic font style embedded and another embedded with no style. Once that was done it worked perfectly.</p>
<p>I thought the whole process was pretty bizarre which is why I&#8217;m posting it. If it doesn&#8217;t benefit anyone else at least it&#8217;ll be here for my own personal reference <img src='http://rabidgadfly.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<p>If you&#8217;re interested, <a href="http://www.rabidgadfly.com/fla/dynhtmltext.zip">here&#8217;s a .fla</a> to demonstrate.</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2007/08/how-to-get-flash-as2-to-display-italicized-html-text/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
		<item>
		<title>Use loadClip to retrieve dynamic properties</title>
		<link>http://rabidgadfly.com/2007/01/use-loadclip-to-retrieve-dynamic-properties/</link>
		<comments>http://rabidgadfly.com/2007/01/use-loadclip-to-retrieve-dynamic-properties/#comments</comments>
		<pubDate>Mon, 08 Jan 2007 19:18:05 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[quickTip]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=17</guid>
		<description><![CDATA[Ever had the need to load an external image and retrieve its height and width, possibly to center it? If you used loadMovie, chances are you just ended up very frustrated because the values returned were either wrong or non-existent. The reason for this is that the code you&#8217;re using to collect the imported object&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Ever had the need to load an external image and retrieve its height and width, possibly to center it? If you used loadMovie, chances are you just ended up very frustrated because the values returned were either wrong or non-existent. The reason for this is that the code you&#8217;re using to collect the imported object&#8217;s properties is executing before the image has finished loading. These situations can be incredibly frustrating and time-consuming to troubleshoot. Especially since, many times, it executes properly from the Flash IDE.</p>
<p>The solution is actually quite simple.</p>
<p><span id="more-17"></span></p>
<p>By utilizing loaders and listeners you can accurately gather all the data you need about an imported object. Here&#8217;s a <a href="fla/loadclip/loadclip.zip">simple example</a>:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_loadclip1_132472734"
			class="flashmovie"
			width="425"
			height="400">
	<param name="movie" value="swf/loadclip/loadclip1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/loadclip/loadclip1.swf"
			name="fm_loadclip1_132472734"
			width="425"
			height="400">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p></p>
<p>As you can see, when loadClip is used, the height and width are properly reported because, by utilizing a listener, we&#8217;ve ensured that we are not requesting properties of an object that is not yet loaded.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2007/01/use-loadclip-to-retrieve-dynamic-properties/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>If /Else Shorthand with the Ternary Operator</title>
		<link>http://rabidgadfly.com/2006/12/if-else-shorthand-with-the-ternary-operator/</link>
		<comments>http://rabidgadfly.com/2006/12/if-else-shorthand-with-the-ternary-operator/#comments</comments>
		<pubDate>Wed, 20 Dec 2006 21:10:08 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[flash]]></category>
		<category><![CDATA[quickTip]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=15</guid>
		<description><![CDATA[I just came across this little shortcut and thought I&#8217;d share. Short, conditional evaulations, such as this&#8230; &#8230;can be written using a conditional, aka ternary, operator (?:), like this: It can become quite a time saver and it condenses your code making it easier to read. -rG]]></description>
			<content:encoded><![CDATA[<p>I just came across this little shortcut and thought I&#8217;d share.</p>
<p>Short, conditional evaulations, such as this&#8230;</p>
<pre class="brush: as3; title: ; notranslate">
var work:String = 'monotonous';
if (work == 'monotonous') {
   activity = 'update blog';
} else {
   activity = 'continue working';
}
trace(activity); //outputs 'update blog'
</pre>
<p>&#8230;can be written using a conditional, aka ternary, operator (?:), like this:</p>
<pre class="brush: as3; title: ; notranslate">
var work:String = 'monotonous';
activity = (work == 'monotonous') ? 'update blog' : 'continue working';
trace(activity); //outputs 'update blog'
</pre>
<p>It can become quite a time saver and it condenses your code making it easier to read.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2006/12/if-else-shorthand-with-the-ternary-operator/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
	</channel>
</rss>

