<?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>Flash, ActionScript, Flash SEO &#187; Code snippets</title>
	<atom:link href="http://flash.sikotiko.com/category/code-snippets/feed/" rel="self" type="application/rss+xml" />
	<link>http://flash.sikotiko.com</link>
	<description>Lessons, ideas, solved problems</description>
	<lastBuildDate>Fri, 30 Jul 2010 08:55:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>[AS3] Code snippets: Useful number methods</title>
		<link>http://flash.sikotiko.com/2009/04/23/as3-number-methods/</link>
		<comments>http://flash.sikotiko.com/2009/04/23/as3-number-methods/#comments</comments>
		<pubDate>Thu, 23 Apr 2009 10:50:58 +0000</pubDate>
		<dc:creator>SikoTiko</dc:creator>
				<category><![CDATA[Code snippets]]></category>
		<category><![CDATA[actionscript 3]]></category>
		<category><![CDATA[number]]></category>
		<category><![CDATA[toFixed]]></category>

		<guid isPermaLink="false">http://flash.sikotiko.com/?p=82</guid>
		<description><![CDATA[Recently I was asked if I know how to show a number with a fixed number of digits after the decimal point. Here is how it can be done: var num:Number = 12.3456; trace&#40;num.toFixed&#40;2&#41;&#41;;// =&#62; 12.34 ATTENTION: This method toFixed returns String. If you want to have a Number after using this method you should [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I was asked if I know how to show a number with a fixed number of digits after the decimal point. Here is how it can be done:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> num<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">12.3456</span>;
<span style="color: #004993;">trace</span><span style="color: #000000;">&#40;</span>num.<span style="color: #004993;">toFixed</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;<span style="color: #009900;">// =&gt; 12.34</span></pre></div></div>

<p><strong>ATTENTION:</strong> This method <em><strong>toFixed</strong></em> returns String. If you want to have a Number after using this method you should use casting or:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #6699cc; font-weight: bold;">var</span> num<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #000000; font-weight:bold;">12.3456</span>;
<span style="color: #6699cc; font-weight: bold;">var</span> num2<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Number</span> = <span style="color: #004993;">Number</span><span style="color: #000000;">&#40;</span>num.<span style="color: #004993;">toFixed</span><span style="color: #000000;">&#40;</span><span style="color: #000000; font-weight:bold;">2</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span>;
<span style="color: #009900;">// =&gt; returns Number not String</span></pre></div></div>

<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://flash.sikotiko.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://flash.sikotiko.com/2009/04/23/as3-number-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Useful ActionScript code snippets: Snippet 1</title>
		<link>http://flash.sikotiko.com/2008/09/08/useful-actionscript-code-snippets/</link>
		<comments>http://flash.sikotiko.com/2008/09/08/useful-actionscript-code-snippets/#comments</comments>
		<pubDate>Mon, 08 Sep 2008 13:32:01 +0000</pubDate>
		<dc:creator>SikoTiko</dc:creator>
				<category><![CDATA[Code snippets]]></category>
		<category><![CDATA[Problems]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ActionScript button]]></category>
		<category><![CDATA[code snippet]]></category>

		<guid isPermaLink="false">http://flash.sikotiko.com/?p=12</guid>
		<description><![CDATA[List of some useful ActionScript code snippets: How to toggle button with two states in two lines of code,i.e. sound on/off button? Let&#8217;s say you have a movieclip called &#8220;sound_btn&#8221; with two frames for the two states &#8211; sound on and sound off. Here is the code: sound_btn.onRelease = function&#40;&#41;&#123; &#160; this.gotoAndStop&#40;Number&#40;soundIsOn&#41;+1&#41;; &#160; soundIsOn = [...]]]></description>
			<content:encoded><![CDATA[<p>List of some useful ActionScript code snippets:</p>
<h2><strong>How to toggle button with two states in two lines of code,i.e. sound on/off button?</strong></h2>
<p>Let&#8217;s say you have a movieclip called &#8220;sound_btn&#8221; with two frames for the two states &#8211; sound on and sound off. Here is the code:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">sound_btn.<span style="color: #0066CC;">onRelease</span> = <span style="color: #000000; font-weight: bold;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #0066CC;">this</span>.<span style="color: #0066CC;">gotoAndStop</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">Number</span><span style="color: #66cc66;">&#40;</span>soundIsOn<span style="color: #66cc66;">&#41;</span>+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
soundIsOn = <span style="color: #66cc66;">!</span>soundIsOn;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>The code <strong>soundIsOn = !soundIsOn;</strong> is equal to:<span id="more-12"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #b1b100;">if</span><span style="color: #66cc66;">&#40;</span>soundIsOn<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
soundIsOn = <span style="color: #000000; font-weight: bold;">false</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #66cc66;">&#123;</span>
&nbsp;
soundIsOn = <span style="color: #000000; font-weight: bold;">true</span>;
&nbsp;
<span style="color: #66cc66;">&#125;</span></pre></div></div>

<p>And the line <strong>this.gotoAndStop(Number(soundIsOn)+1);</strong> sends the movie clip to a frame number depending on the value of the Boolean variable soundIsOn. Number(soundIsOn) = 1 if soundIsOn = true, and Number(soundIsOn) = 0 if soundIsOn = false.</p>
<p><a class="a2a_dd addtoany_share_save" href="http://www.addtoany.com/share_save"><img src="http://flash.sikotiko.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share/Bookmark"/></a> </p>]]></content:encoded>
			<wfw:commentRss>http://flash.sikotiko.com/2008/09/08/useful-actionscript-code-snippets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
