<?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>ABCoder &#187; Actionscript 2</title>
	<atom:link href="http://abcoder.com/topics/flash/actionscript-2/feed/" rel="self" type="application/rss+xml" />
	<link>http://abcoder.com</link>
	<description>ABCoder - Coding is Simple as A b c</description>
	<lastBuildDate>Sat, 17 Jul 2010 11:45:42 +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>Calling a function randomly / arbitrarily</title>
		<link>http://abcoder.com/flash/calling-a-function-randomly-arbitrarily/</link>
		<comments>http://abcoder.com/flash/calling-a-function-randomly-arbitrarily/#comments</comments>
		<pubDate>Fri, 26 Jun 2009 11:21:53 +0000</pubDate>
		<dc:creator>saif</dc:creator>
				<category><![CDATA[Actionscript 2]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[actionscript]]></category>
		<category><![CDATA[actionscrtipt2]]></category>
		<category><![CDATA[as2]]></category>
		<category><![CDATA[random function calling]]></category>
		<category><![CDATA[random function choosing]]></category>

		<guid isPermaLink="false">http://abcoder.com/?p=102</guid>
		<description><![CDATA[randomly calling a function, randomly choosing a function


No related posts.]]></description>
			<content:encoded><![CDATA[<p>Say you have 2 or more functions in your actionscript, for some reason you have to call one of them arbitrary and dynamically. You don’t know which function will call at run time. You can do it by this way….</p>
<pre class="brush: as3;">var myfunctions:Array = new Array();
myfunctions[0] = &quot;myfunc1&quot;;
myfunctions[1] = &quot;myfunc2&quot;;
myfunctions[2] = &quot;myfunc3&quot;;

function  myfunc1 (){
   trace(&quot;This is my function number 1&quot;);
}
function  myfunc2 (){
   trace(&quot;This is my function number 2&quot;);
}
function  myfunc3 (){
   trace(&quot;This is my function number 3&quot;);
}

function randRange(min:Number, max:Number):Number {
   var randNum:Number = Math.round(Math.random()*(max-min))+min;
   return randNum;
}
btn.onPress = function(){
   var randomNumber = randRange(0,myfunctions.length-1);
   _root[myfunctions[randomNumber]]();
}</pre>


<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://abcoder.com/flash/calling-a-function-randomly-arbitrarily/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
