<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: functions code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Fri, 25 Jul 2008 07:28:30 GMT</pubDate>
    <description>DZone Snippets: functions code</description>
    <item>
      <title>Random Number</title>
      <link>http://snippets.dzone.com/posts/show/5316</link>
      <description>function randRange(min:Number, max:Number):Number {&lt;br /&gt;    var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;&lt;br /&gt;    return randomNum;&lt;br /&gt;}</description>
      <pubDate>Wed, 02 Apr 2008 18:13:06 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5316</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>collapseWhiteSpace</title>
      <link>http://snippets.dzone.com/posts/show/5315</link>
      <description>function collapseWhiteSpace(theString:String):String &lt;br /&gt;{&lt;br /&gt;	theString =  theString.split("\r").join("");&lt;br /&gt;	theString =  theString.split("\t").join("");&lt;br /&gt;	while ( theString.indexOf("  " ) != -1 ) {&lt;br /&gt;		theString= theString.split("  ").join(" ");&lt;br /&gt;	}&lt;br /&gt;	if (theString.substr(0,1) == " ") {&lt;br /&gt;		theString = theString.substr( 1 );&lt;br /&gt;	}&lt;br /&gt;	if (theString.substr( theString.length-1, 1 ) == " ") {&lt;br /&gt;		theString = theString.substr( 0, theString.length - 1 );&lt;br /&gt;	}&lt;br /&gt;	return(theString);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;trace(collapseWhiteSpace("hai rajesh how are you"));</description>
      <pubDate>Wed, 02 Apr 2008 18:05:47 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5315</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Arguments</title>
      <link>http://snippets.dzone.com/posts/show/5307</link>
      <description>/*&lt;br /&gt;function traceFunctions():Void {&lt;br /&gt;for (var i=0; i &lt; arguments.length; i++){&lt;br /&gt;trace(arguments[i]);&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;traceFunctions("One","Two");&lt;br /&gt;*/</description>
      <pubDate>Wed, 02 Apr 2008 02:46:38 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5307</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Arguments.caller</title>
      <link>http://snippets.dzone.com/posts/show/5306</link>
      <description>/*&lt;br /&gt;function function1():Void{&lt;br /&gt;function2();&lt;br /&gt;}&lt;br /&gt;function function2():Void{&lt;br /&gt;if(arguments.caller == function1)&lt;br /&gt;trace("function2 called from function1");&lt;br /&gt;else&lt;br /&gt;trace("function2 not called from function1");&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function1();&lt;br /&gt;function2();&lt;br /&gt;*/</description>
      <pubDate>Wed, 02 Apr 2008 02:45:36 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5306</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Referencing Functions</title>
      <link>http://snippets.dzone.com/posts/show/5305</link>
      <description>function CalculateArea(a:Number, b:Number):Number&lt;br /&gt;{&lt;br /&gt;var nArea:Number = a*b;&lt;br /&gt;return nArea&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;var fCalculate:Function = CalculateArea;&lt;br /&gt;trace(fCalculate(6,6));&lt;br /&gt;</description>
      <pubDate>Wed, 02 Apr 2008 02:39:48 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5305</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Anonmyous Function</title>
      <link>http://snippets.dzone.com/posts/show/5303</link>
      <description>var fSayHi:Function = function(sName:String):Void {&lt;br /&gt;trace("Hi, " + sName);&lt;br /&gt;};&lt;br /&gt;fSayHi("Joey"); // Displays: Hi, Joey</description>
      <pubDate>Wed, 02 Apr 2008 02:00:28 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5303</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Creating Recursion Function</title>
      <link>http://snippets.dzone.com/posts/show/5302</link>
      <description>function factorial(nOperand:Number):Number {&lt;br /&gt;	if (nOperand&gt;0) {&lt;br /&gt;		return nOperand*factorial(nOperand-1);&lt;br /&gt;	} else {&lt;br /&gt;		return 1;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;trace(factorial(5));</description>
      <pubDate>Wed, 02 Apr 2008 01:59:41 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5302</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>Overloading a Function</title>
      <link>http://snippets.dzone.com/posts/show/5301</link>
      <description>//Overloading a Function&lt;br /&gt;function fCalculateArea():Number{&lt;br /&gt;	switch (arguments.length){&lt;br /&gt;		case 1:&lt;br /&gt;			var nRadius = arguments[0];&lt;br /&gt;			return nRadius * nRadius;&lt;br /&gt;		case 2:&lt;br /&gt;			var nA = arguments[0];&lt;br /&gt;			var nB = arguments[1];&lt;br /&gt;			return nA * nB;&lt;br /&gt;	}&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;trace(fCalculateArea(5,2));</description>
      <pubDate>Wed, 02 Apr 2008 01:54:11 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5301</guid>
      <author>rcube9 (rajesh)</author>
    </item>
    <item>
      <title>str_hex and hex_str</title>
      <link>http://snippets.dzone.com/posts/show/2039</link>
      <description>// Convert hex to string and vice versa.&lt;br /&gt;//&lt;br /&gt;// (Source: http://codedump.jonasjohn.de/)&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;function str_hex($string){&lt;br /&gt;    $hex='';&lt;br /&gt;    for ($i=0; $i &lt; strlen($string); $i++){&lt;br /&gt;        $hex .= dechex(ord($string[$i]));&lt;br /&gt;    }&lt;br /&gt;    return $hex;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;function hex_str($hex){&lt;br /&gt;    $string='';&lt;br /&gt;    for ($i=0; $i &lt; strlen($hex)-1; $i+=2){&lt;br /&gt;        $string .= chr(hexdec($hex[$i].$hex[$i+1]));&lt;br /&gt;    }&lt;br /&gt;    return $string;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;// example:&lt;br /&gt;&lt;br /&gt;$hex = str_hex("test sentence...");&lt;br /&gt;// $hex contains 746573742073656e74656e63652e2e2e&lt;br /&gt;&lt;br /&gt;print hex_str($hex);&lt;br /&gt;// outputs: test sentence...&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Tue, 16 May 2006 01:41:34 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/2039</guid>
      <author>jonasj (Jonas J.)</author>
    </item>
  </channel>
</rss>
