<?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>Actionscript 3 Designer Toolkit</title>
	<atom:link href="http://www.as3dtk.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.as3dtk.com</link>
	<description>More design, less programming</description>
	<lastBuildDate>Thu, 03 Jun 2010 14:03:36 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Displaying multiple pages:  the SelectedPage class</title>
		<link>http://www.as3dtk.com/?p=521</link>
		<comments>http://www.as3dtk.com/?p=521#comments</comments>
		<pubDate>Thu, 03 Jun 2010 13:59:07 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[display]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[jpg]]></category>
		<category><![CDATA[swf]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=521</guid>
		<description><![CDATA[The SelectedPage class displays a series of jpeg&#8217;s and/or swf&#8217;s one at a time.&#160;&#160;A series of buttons &#8211; one for each page &#8211; control the tweened transistion from one page to the next.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_selectedPage_917060795"
			align="left"
			class="flashmovie"
			width="490"
			height="270">
	<param name="movie" value="swf/selectedPage.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/selectedPage.swf"
			name="fm_selectedPage_917060795"
			align="left"
			width="490"
			height="270">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

The class relies on two arrays for data.&#160;&#160;As in the sample code example below, the [...]]]></description>
			<content:encoded><![CDATA[<p>The<strong> SelectedPage</strong> class displays a series of jpeg&#8217;s and/or swf&#8217;s one at a time.&nbsp;&nbsp;A series of buttons &#8211; one for each page &#8211; control the tweened transistion from one page to the next.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_selectedPage_460523766"
			align="left"
			class="flashmovie"
			width="490"
			height="270">
	<param name="movie" value="swf/selectedPage.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/selectedPage.swf"
			name="fm_selectedPage_460523766"
			align="left"
			width="490"
			height="270">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-521"></span></p>
<p>The class relies on two arrays for data.&nbsp;&nbsp;As in the sample code example below, the first array <em>urls</em> defines the urls of each page and the second <em>buttonProps</em> defines all the properties of the circular selector buttons.&nbsp;&nbsp;Button properties include the radius, horizontal spacing between each button, their offsets from the left edge and bottom of the page, outline, selected and default colors.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p5212"><td class="code" id="p521code2"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import custom class</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">SelectedPage</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// array of page url's</span>
<span style="color: #000000; font-weight: bold;">var</span> urls:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> <span style="color: #41ac44;">'blue-doors.jpg'</span>, <span style="color: #41ac44;">'driveway.jpg'</span>,<span style="color: #41ac44;">'gray-garage.jpg'</span>, <span style="color: #41ac44;">'2930.jpg'</span>, <span style="color: #41ac44;">'tow-wall.jpg'</span>  <span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of selector button properties</span>
<span style="color: #000000; font-weight: bold;">var</span> buttonProps:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
buttonProps.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> buttonRadius: <span style="color: #cc66cc;">10</span>, buttonSpacing: <span style="color: #cc66cc;">30</span>, buttonXOffset: <span style="color: #cc66cc;">10</span>, buttonYOffset: <span style="color: #cc66cc;">10</span>, 
				 	buttonLineColor: 0x222222, buttonColor: 0xffffff, selectedButtonColor: 0x9d9d9d <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// new instance of SelectedPage class</span>
<span style="color: #808080; font-style: italic;">// params: pageID, firstInstance, pathToPages, array of url's, pgWidth, pgHeight, array of button properties</span>
<span style="color: #000000; font-weight: bold;">var</span> p:SelectedPage = <span style="color: #000000; font-weight: bold;">new</span> SelectedPage<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">true</span>, <span style="color: #41ac44;">'images/'</span>, urls, <span style="color: #cc66cc;">360</span>, <span style="color: #cc66cc;">225</span>, buttonProps <span style="color: #66cc66;">&#41;</span>;
p.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
p.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;
addChild<span style="color: #66cc66;">&#40;</span> p <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>The download includes all the files required to produce the above example.&nbsp;&nbsp; <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=67" title=" downloaded 31 times" >SelectedPage.zip (31)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=521</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing lines of alternating dots and dashes:  the DashDotLine class</title>
		<link>http://www.as3dtk.com/?p=520</link>
		<comments>http://www.as3dtk.com/?p=520#comments</comments>
		<pubDate>Thu, 27 May 2010 13:59:24 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=520</guid>
		<description><![CDATA[A visitor asked whether the DashedLine class could be modified to create lines composed of alternating dots and dashes; so I went ahead and modified the class.&#160;&#160;The new DashDotLine class constructor includes parameters for total length of the line, dash and dot widths, spacing between the dashes and dots and line weight and color.
]]></description>
			<content:encoded><![CDATA[<p>A visitor asked whether the <strong><a href="http://www.as3dtk.com/?p=35">DashedLine</a></strong> class could be modified to create lines composed of alternating dots and dashes; so I went ahead and modified the class.&nbsp;&nbsp;The new <strong>DashDotLine</strong> class constructor includes parameters for total length of the line, dash and dot widths, spacing between the dashes and dots and line weight and color.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_dashdot_1607830345"
			align="left"
			class="flashmovie"
			width="490"
			height="20">
	<param name="movie" value="swf/dashdot.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/dashdot.swf"
			name="fm_dashdot_1607830345"
			align="left"
			width="490"
			height="20">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-520"></span></p>
<p>The core of the the <strong>DashDotLine</strong> class is a <em>while</em> loop that repetitively draws a dash, adds a space, draws a dot and adds another space.&nbsp;&nbsp;This is repeated until the length of the newly drawn line exceeds the line length specified as a constructor parameter.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p5205"><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
</pre></td><td class="code" id="p520code5"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// container to hold all dots &amp;amp; dashes</span>
<span style="color: #000000; font-weight: bold;">var</span> line:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// initialize starting point of line</span>
xPos = <span style="color: #cc66cc;">0</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// loop through drawing dashes &amp; dots</span>
<span style="color: #b1b100;">while</span> <span style="color: #66cc66;">&#40;</span> xPos <span style="color: #66cc66;">&lt;</span> lineLength <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// draw dash</span>
	<span style="color: #000000; font-weight: bold;">var</span> dash:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
	dash.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> lineColor <span style="color: #66cc66;">&#41;</span>;
	dash.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> xPos, <span style="color: #cc66cc;">0</span>, dashWidth, lineWeight <span style="color: #66cc66;">&#41;</span>;
	dash.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
	line.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> dash <span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// increment xPos by dash width + spacing</span>
	xPos += <span style="color: #66cc66;">&#40;</span> dashWidth + spacing <span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// draw dot</span>
	<span style="color: #000000; font-weight: bold;">var</span> dot:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
	dot.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> lineWeight <span style="color: #66cc66;">&#41;</span>;
	dot.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> xPos, <span style="color: #cc66cc;">0</span>, dotWidth, lineWeight <span style="color: #66cc66;">&#41;</span>;
	dot.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
	line.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span> dot <span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// increment xPos by dot width + spacing</span>
	xPos += <span style="color: #66cc66;">&#40;</span> dotWidth + spacing <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
addChild<span style="color: #66cc66;">&#40;</span> line <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Use the code below to create an instance of the class.&nbsp;&nbsp;Note:&nbsp;&nbsp;to make the line vertical use the <em>rotation</em> property.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p5206"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p520code6"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">DashDotLine</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// new instance with parameters line length, dash width, dot width, spacing, line weight, line color</span>
<span style="color: #000000; font-weight: bold;">var</span> line:DashDotLine = <span style="color: #000000; font-weight: bold;">new</span> DashDotLine <span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">360</span>, <span style="color: #cc66cc;">16</span>, <span style="color: #cc66cc;">7</span>, <span style="color: #cc66cc;">4</span>, <span style="color: #cc66cc;">2</span>, 0x000000 <span style="color: #66cc66;">&#41;</span>;
line.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">20</span>;
line.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">20</span>;
line.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">90</span>;  <span style="color: #808080; font-style: italic;">// option to make the line vertical</span>
addChild<span style="color: #66cc66;">&#40;</span> line <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Download files:   <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=66" title=" downloaded 45 times" >DashDotLine.as (45)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=520</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Removing class instances</title>
		<link>http://www.as3dtk.com/?p=518</link>
		<comments>http://www.as3dtk.com/?p=518#comments</comments>
		<pubDate>Thu, 20 May 2010 14:57:48 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[getChildAt]]></category>
		<category><![CDATA[removeChildAt]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=518</guid>
		<description><![CDATA[A reader recently inquired if it was necessary to remove previously created class instances which were no longer being used.&#160;&#160;The simple answer is yes because it frees up memory &#8211; but there may be other reasons as well.


// import custom classes
import com.dtk.ImageLoader;
import com.dtk.HTMLTitle;
import com.dtk.SelectedImageEvent;
&#160;
// load first image &#38; title
dispatchEvent&#40; new SelectedImageEvent&#40; SelectedImageEvent.IMAGE_SELECTED, 0 &#41;&#41;;
&#160;
/**
 *	display [...]]]></description>
			<content:encoded><![CDATA[<p>A reader recently inquired if it was necessary to remove previously created class instances which were no longer being used.&nbsp;&nbsp;The simple answer is yes because it frees up memory &#8211; but there may be other reasons as well.</p>
<p><span id="more-518"></span></p>

<div class="wp_codebox"><table width="100%" ><tr id="p5188"><td class="code" id="p518code8"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import custom classes</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">ImageLoader</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">HTMLTitle</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">SelectedImageEvent</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// load first image &amp; title</span>
dispatchEvent<span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">new</span> SelectedImageEvent<span style="color: #66cc66;">&#40;</span> SelectedImageEvent.<span style="color: #006600;">IMAGE_SELECTED</span>, <span style="color: #cc66cc;">0</span> <span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">/**
 *	display image and title of image
 *
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> imageHandler<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:SelectedImageEvent <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
        <span style="color: #808080; font-style: italic;">// remove class instances from screen</span>
	removeFromView<span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'image'</span> <span style="color: #66cc66;">&#41;</span>;
	removeFromView<span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'title'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// display large image</span>
	<span style="color: #000000; font-weight: bold;">var</span> vw:ImageViewer = <span style="color: #000000; font-weight: bold;">new</span> ImageViewer<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">imageID</span>, <span style="color: #cc66cc;">420</span>, <span style="color: #cc66cc;">420</span> <span style="color: #66cc66;">&#41;</span>;
	vw.<span style="color: #006600;">x</span> = xImage;
	vw.<span style="color: #006600;">y</span> = yImage;
	vw.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> SelectedImageEvent.<span style="color: #006600;">IMAGE_SELECTED</span>, imageHandler <span style="color: #66cc66;">&#41;</span>;
	vw.<span style="color: #0066CC;">name</span> = <span style="color: #41ac44;">'image'</span>;
	addChild<span style="color: #66cc66;">&#40;</span> vw <span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">// display title of image</span>
	<span style="color: #000000; font-weight: bold;">var</span> it:HTMLTitle = <span style="color: #000000; font-weight: bold;">new</span> HTMLTitle<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">imageID</span>, <span style="color: #41ac44;">'Verdana'</span>, <span style="color: #cc66cc;">13</span>, 0x666666, <span style="color: #41ac44;">'LEFT'</span> <span style="color: #66cc66;">&#41;</span>;
	it.<span style="color: #006600;">x</span> = xTitle;
	it.<span style="color: #006600;">y</span> = yTitle;
	it.<span style="color: #0066CC;">name</span> = <span style="color: #41ac44;">'title'</span>;
	addChild<span style="color: #66cc66;">&#40;</span> it <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">/**
 *	remove named class instance
 *
 */</span>
<span style="color: #000000; font-weight: bold;">function</span> removeFromView<span style="color: #66cc66;">&#40;</span> className:<span style="color: #0066CC;">String</span> <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// loop through all existing instances</span>
	<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>numChildren; i++ <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #808080; font-style: italic;">// test for match to var className</span>
		<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span> getChildAt<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">name</span> == className <span style="color: #66cc66;">&#41;</span>
		<span style="color: #66cc66;">&#123;</span>
			<span style="color: #808080; font-style: italic;">// remove instance</span>
			removeChildAt<span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">&#41;</span>;
		<span style="color: #66cc66;">&#125;</span>
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>In the above code snippet, the <strong>ImageViewer</strong> and the <strong>HTMLTitle</strong> classes are used to display an image and its title.&nbsp;&nbsp;Additional functionality allows the user  to click on the image to load the next image and title.&nbsp;&nbsp;If all the images are the same size only the top image is visible; but, if the images vary in size, then portions of previously loaded images will be visible.</p>
<p>In this case, the <em>removeFromView( )</em> function is required to clear the screen of images that may otherwise overlap.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=518</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Displaying slides:  the SlideShow class</title>
		<link>http://www.as3dtk.com/?p=515</link>
		<comments>http://www.as3dtk.com/?p=515#comments</comments>
		<pubDate>Wed, 12 May 2010 14:45:18 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[image]]></category>
		<category><![CDATA[jpeg]]></category>
		<category><![CDATA[next]]></category>
		<category><![CDATA[previous]]></category>
		<category><![CDATA[slideshow]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=515</guid>
		<description><![CDATA[The SlideShow class is a simple means for displaying jpeg images one at a time.&#160;&#160;The class has built in next and previous buttons and shows the slide number displayed and total number of slides.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_slideshow_1743462447"
			align="left"
			class="flashmovie"
			width="490"
			height="270">
	<param name="movie" value="swf/slideshow.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/slideshow.swf"
			name="fm_slideshow_1743462447"
			align="left"
			width="490"
			height="270">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

The Flash file below implements the slideshow above.&#160;&#160;After importing the SlideShow class, an array [...]]]></description>
			<content:encoded><![CDATA[<p>The <strong>SlideShow</strong> class is a simple means for displaying jpeg images one at a time.&nbsp;&nbsp;The class has built in next and previous buttons and shows the slide number displayed and total number of slides.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_slideshow_1739198391"
			align="left"
			class="flashmovie"
			width="490"
			height="270">
	<param name="movie" value="swf/slideshow.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/slideshow.swf"
			name="fm_slideshow_1739198391"
			align="left"
			width="490"
			height="270">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-515"></span></p>
<p>The Flash file below implements the slideshow above.&nbsp;&nbsp;After importing the SlideShow class, an array <em>slides</em> defines the url, width and height of each slide to be displayed.&nbsp;&nbsp;The containing frame&#8217;s dimensions &#8211; always equal to or larger than the slides &#8211; is then defined along with its fill and border color.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p51510"><td class="code" id="p515code10"><pre class="actionscript" style="font-family:monospace;"><span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">SlideShow</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of slides to display with url, width &amp; height</span>
<span style="color: #000000; font-weight: bold;">var</span> slides:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/2930.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">200</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">125</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/blue-corrugated.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">200</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">125</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/blue-doors.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">200</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">125</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/gate.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">125</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/gray-garage.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">200</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">125</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
slides.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">url</span>: <span style="color: #41ac44;">'http://www.as3dtk.com/swf/wp-images/window.jpg'</span>, <span style="color: #0066CC;">width</span>: <span style="color: #cc66cc;">125</span>, <span style="color: #0066CC;">height</span>: <span style="color: #cc66cc;">200</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// containing frame dimensions, fill &amp; line color</span>
<span style="color: #000000; font-weight: bold;">var</span> frameWidth:uint     = <span style="color: #cc66cc;">200</span>;
<span style="color: #000000; font-weight: bold;">var</span> frameHeight:uint    = <span style="color: #cc66cc;">200</span>;
<span style="color: #000000; font-weight: bold;">var</span> frameBGColor:uint   = 0xeeeeee;
<span style="color: #000000; font-weight: bold;">var</span> frameLineColor:uint = 0x999999;
&nbsp;
<span style="color: #808080; font-style: italic;">// instance of SlideShow class</span>
<span style="color: #000000; font-weight: bold;">var</span> ss:SlideShow = <span style="color: #000000; font-weight: bold;">new</span> SlideShow<span style="color: #66cc66;">&#40;</span> slides, frameWidth, frameWidth, frameBGColor, frameLineColor <span style="color: #66cc66;">&#41;</span>;
ss.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
ss.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">10</span>;
addChild<span style="color: #66cc66;">&#40;</span> ss <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

<p>Download files:   <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=65" title=" downloaded 41 times" >SlideShow.zip (41)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=515</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using patterned backgrounds and masks:  the Perf class</title>
		<link>http://www.as3dtk.com/?p=513</link>
		<comments>http://www.as3dtk.com/?p=513#comments</comments>
		<pubDate>Tue, 04 May 2010 13:25:37 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[mask]]></category>
		<category><![CDATA[perf]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=513</guid>
		<description><![CDATA[The Perf class draws a regular grid of either squares or circles that can then be applied as either a background or as a mask.&#160;&#160;The parameters of the class constructor determine whether the pattern is composed of squares or circles, the spacing and size of the pattern and its color and transparency. 
]]></description>
			<content:encoded><![CDATA[<p>The <strong>Perf</strong> class draws a regular grid of either squares or circles that can then be applied as either a background or as a mask.&nbsp;&nbsp;The parameters of the class constructor determine whether the pattern is composed of squares or circles, the spacing and size of the pattern and its color and transparency. </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_perf_353449768"
			align="left"
			class="flashmovie"
			width="490"
			height="330">
	<param name="movie" value="swf/perf.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/perf.swf"
			name="fm_perf_353449768"
			align="left"
			width="490"
			height="330">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-513"></span></p>
<p>The top instance above is a circular gray pattern with a transparency of .4 and the bottom instance is a square pattern which is then applied as a mask over the jpeg image.&nbsp;&nbsp;The download includes the code below and the 2 classes used.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p51312"><td class="code" id="p513code12"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import required dtk classes</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">Perf</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">ImageLoader</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// black rectangle</span>
<span style="color: #000000; font-weight: bold;">var</span> bg:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
bg.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span> 0x000000 <span style="color: #66cc66;">&#41;</span>;
bg.<span style="color: #006600;">graphics</span>.<span style="color: #006600;">drawRect</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">100</span>, <span style="color: #cc66cc;">42</span>, <span style="color: #cc66cc;">200</span>, <span style="color: #cc66cc;">76</span> <span style="color: #66cc66;">&#41;</span>;
bg.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> bg <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Perf instance with gray, transparent circles on top of black rectangle</span>
<span style="color: #000000; font-weight: bold;">var</span> pf1:Perf = <span style="color: #000000; font-weight: bold;">new</span> Perf<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #000000; font-weight: bold;">false</span>, 0xcccccc, .4, <span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">160</span> <span style="color: #66cc66;">&#41;</span>;
pf1.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">0</span>;
pf1.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">0</span>;
addChild<span style="color: #66cc66;">&#40;</span> pf1 <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// load jpeg as background</span>
<span style="color: #000000; font-weight: bold;">var</span> im:ImageLoader = <span style="color: #000000; font-weight: bold;">new</span> ImageLoader<span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'images/garage.jpg'</span>, <span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">160</span>, 0xff0000 <span style="color: #66cc66;">&#41;</span>;
im.<span style="color: #006600;">x</span> =   <span style="color: #cc66cc;">0</span>;
im.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">160</span>;
addChild<span style="color: #66cc66;">&#40;</span> im <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// Perf instance with square pattern to be used as mask</span>
<span style="color: #000000; font-weight: bold;">var</span> pf2:Perf = <span style="color: #000000; font-weight: bold;">new</span> Perf<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">40</span>, <span style="color: #cc66cc;">36</span>, <span style="color: #000000; font-weight: bold;">true</span>, 0xff0000, <span style="color: #cc66cc;">1</span>, <span style="color: #cc66cc;">400</span>, <span style="color: #cc66cc;">160</span> <span style="color: #66cc66;">&#41;</span>;
pf2.<span style="color: #006600;">x</span> =   <span style="color: #cc66cc;">0</span>;
pf2.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">160</span>;
addChild<span style="color: #66cc66;">&#40;</span> pf2 <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// mask image with Perf instance</span>
im.<span style="color: #006600;">mask</span> = pf2;</pre></td></tr></table></div>

 <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=64" title=" downloaded 39 times" >Perf.zip (39)</a> 
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=513</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drawing a checkerboard background:  the Checkerboard class</title>
		<link>http://www.as3dtk.com/?p=511</link>
		<comments>http://www.as3dtk.com/?p=511#comments</comments>
		<pubDate>Tue, 27 Apr 2010 13:48:16 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[checkerboard]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[drawing]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=511</guid>
		<description><![CDATA[This post introduces the Checkerboard drawing class.&#160;&#160;It is a simple and easy to use class that relies on Flash&#8217;s BitmapData class to draw the patterns.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_checkerboard_1873940799"
			align="left"
			class="flashmovie"
			width="490"
			height="180">
	<param name="movie" value="swf/checkerboard.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/checkerboard.swf"
			name="fm_checkerboard_1873940799"
			align="left"
			width="490"
			height="180">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

The code below implements the image above.&#160;&#160;Notice that where the text instances are instanciated determines their z-order and, therefore, their positions relative to [...]]]></description>
			<content:encoded><![CDATA[<p>This post introduces the <strong>Checkerboard</strong> drawing class.&nbsp;&nbsp;It is a simple and easy to use class that relies on Flash&#8217;s BitmapData class to draw the patterns.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_checkerboard_693257066"
			align="left"
			class="flashmovie"
			width="490"
			height="180">
	<param name="movie" value="swf/checkerboard.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/checkerboard.swf"
			name="fm_checkerboard_693257066"
			align="left"
			width="490"
			height="180">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-511"></span></p>
<p>The code below implements the image above.&nbsp;&nbsp;Notice that where the text instances are instanciated determines their z-order and, therefore, their positions relative to the checkerboard.&nbsp;&nbsp;The Checkerboard class included in the download below is well commented (refer to the class for an explanation of the constructor parameters required).</p>

<div class="wp_codebox"><table width="100%" ><tr id="p51114"><td class="code" id="p511code14"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import required dtk classes</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">Checkerboard</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #0066CC;">HTMLText</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// display text behind checkerboard</span>
<span style="color: #000000; font-weight: bold;">var</span> b:<span style="color: #0066CC;">HTMLText</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">HTMLText</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">300</span>, <span style="color: #41ac44;">'Times New Roman'</span>, <span style="color: #cc66cc;">48</span>, 0x000000, <span style="color: #41ac44;">'LEFT'</span>, <span style="color: #41ac44;">'&lt;b&gt;Below&lt;/b&gt;'</span> <span style="color: #66cc66;">&#41;</span>;
b.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">100</span>;
b.<span style="color: #006600;">y</span> =  <span style="color: #cc66cc;">30</span>;
addChild<span style="color: #66cc66;">&#40;</span> b <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// draw checkerboard pattern</span>
<span style="color: #000000; font-weight: bold;">var</span> cb:Checkerboard = <span style="color: #000000; font-weight: bold;">new</span> Checkerboard<span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">20</span>, 0xffcc00, 0x000000, <span style="color: #cc66cc;">480</span>, <span style="color: #cc66cc;">180</span> <span style="color: #66cc66;">&#41;</span>;
cb.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">0</span>;
cb.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">0</span>;
cb.<span style="color: #006600;">alpha</span> = .5;  <span style="color: #808080; font-style: italic;">// optional</span>
addChild<span style="color: #66cc66;">&#40;</span> cb <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// display text in front of checkerboard</span>
<span style="color: #000000; font-weight: bold;">var</span> a:<span style="color: #0066CC;">HTMLText</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">HTMLText</span><span style="color: #66cc66;">&#40;</span> <span style="color: #cc66cc;">300</span>, <span style="color: #41ac44;">'Times New Roman'</span>, <span style="color: #cc66cc;">48</span>, 0x000000, <span style="color: #41ac44;">'LEFT'</span>, <span style="color: #41ac44;">'&lt;b&gt;Above&lt;/b&gt;'</span> <span style="color: #66cc66;">&#41;</span>;
a.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">200</span>;
a.<span style="color: #006600;">y</span> =  <span style="color: #cc66cc;">80</span>;
addChild<span style="color: #66cc66;">&#40;</span> a <span style="color: #66cc66;">&#41;</span>;</pre></td></tr></table></div>

 <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=63" title=" downloaded 45 times" >Checkerboard.zip (45)</a> 
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=511</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Submit your site</title>
		<link>http://www.as3dtk.com/?p=505</link>
		<comments>http://www.as3dtk.com/?p=505#comments</comments>
		<pubDate>Tue, 20 Apr 2010 14:00:18 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[download]]></category>
		<category><![CDATA[submission]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=505</guid>
		<description><![CDATA[Since the Actionscript 3 Designer Toolkit came online &#8211; over eight months ago &#8211; visitors to this website have downloaded the posted code snippets and custom classes several thousand times.
If you are a designer/developer who has used one or more of the AS3DTK custom classes in a website you built, please let us know.&#160;&#160;Send the [...]]]></description>
			<content:encoded><![CDATA[<p>Since the Actionscript 3 Designer Toolkit came online &#8211; over eight months ago &#8211; visitors to this website have downloaded the posted code snippets and custom classes several thousand times.</p>
<p>If you are a designer/developer who has used one or more of the AS3DTK custom classes in a website you built, please let us know.&nbsp;&nbsp;Send the url of the site and perhaps a short description of how you applied the class(es) on the site.&nbsp;&nbsp;Submitted urls will then be listed on a special page with your name and email (optional).</p>
<p>Also, if you have any ideas or suggestions for future posts let us know.</p>
<p>To respond, you may add a comment or email me <a href="mailto:csdavis@sent.com"><u>csdavis@sent.com</u></a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=505</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Applying the DropDownMenus class</title>
		<link>http://www.as3dtk.com/?p=503</link>
		<comments>http://www.as3dtk.com/?p=503#comments</comments>
		<pubDate>Tue, 13 Apr 2010 13:19:15 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[menus]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=503</guid>
		<description><![CDATA[In this post, the DropDownMenus class is used to form a group of horizontally arranged dropdown menus.&#160;&#160;Several changes have been made to the class to enable multiple instances to work more efficently together (changes detailed below).

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_horizontal_701325107"
			align="left"
			class="flashmovie"
			width="490"
			height="220">
	<param name="movie" value="swf/horizontal.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/horizontal.swf"
			name="fm_horizontal_701325107"
			align="left"
			width="490"
			height="220">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

The first change is a new parameter menuID added to the class [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, the <strong>DropDownMenus</strong> class is used to form a group of horizontally arranged dropdown menus.&nbsp;&nbsp;Several changes have been made to the class to enable multiple instances to work more efficently together (changes detailed below).</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_horizontal_1806549442"
			align="left"
			class="flashmovie"
			width="490"
			height="220">
	<param name="movie" value="swf/horizontal.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/horizontal.swf"
			name="fm_horizontal_1806549442"
			align="left"
			width="490"
			height="220">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-503"></span></p>
<p>The first change is a new parameter <em>menuID</em> added to the class constructor.&nbsp;&nbsp;Each instance gets a different value &#8211; each a multiple of 10 &#8211; and is used to identify both the menu and submenu item selected.&nbsp;&nbsp;Refer to the <em>onMenuTabSelected</em> function in the .fla to see the logic that decodes both the menu and submenu id.</p>
<p>A second change made is that rather than passing the constructor an array named tabs, the constructor is passed a single element of the array tabs which is a string composed of a comma separated list of submenu tab titles.&nbsp;&nbsp;This list is then converted back to an array within the class.</p>
<p>A final change is that rather than passing the constructor a separate title for each menu, an array of all the titles is passed.&nbsp;&nbsp;The class itself then, extracts the proper title based on its index.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p50316"><td class="code" id="p503code16"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import required classes</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">DropDownMenus</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">MenuTabSelected</span>;
<span style="color: #0066CC;">import</span> caurina.<span style="color: #006600;">transitions</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// init vars passed to class instance</span>
<span style="color: #000000; font-weight: bold;">var</span> bgWidth:uint  = <span style="color: #cc66cc;">156</span>;
<span style="color: #000000; font-weight: bold;">var</span> bgHeight:uint =  <span style="color: #cc66cc;">60</span>;
<span style="color: #000000; font-weight: bold;">var</span> bgColor:uint  = 0x1073d1;
<span style="color: #000000; font-weight: bold;">var</span> spacing:uint  =   <span style="color: #cc66cc;">3</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// starting y position of topmost menus</span>
<span style="color: #000000; font-weight: bold;">var</span> xStart:uint = <span style="color: #cc66cc;">10</span>;
<span style="color: #000000; font-weight: bold;">var</span> xPos:uint   = xStart;
<span style="color: #000000; font-weight: bold;">var</span> yPos:uint   = <span style="color: #cc66cc;">0</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of menu titles</span>
<span style="color: #000000; font-weight: bold;">var</span> titles:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> <span style="color: #41ac44;">'Video'</span>, <span style="color: #41ac44;">'Audio'</span>, <span style="color: #41ac44;">'Car'</span> <span style="color: #66cc66;">&#93;</span>;
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of submenu tab titles</span>
<span style="color: #000000; font-weight: bold;">var</span> tabs:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// each array entry is formatted as a string of comma seperated values; each value a submenu tab titles</span>
tabs.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'Televisions,Projectors,BlueRay &amp; DVD,Home Theatre,TiVo'</span> <span style="color: #66cc66;">&#41;</span>;
tabs.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'iPod/MP3 Players,Audio Systems,Home Theatre,Headphones,Speakers'</span> <span style="color: #66cc66;">&#41;</span>;
tabs.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'GPS Navigation,Satellite Radio,Digital Radio,Car Audio'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of properties defining menu's main title</span>
<span style="color: #000000; font-weight: bold;">var</span> titleProps:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
titleProps.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> titleXOffset: <span style="color: #cc66cc;">2</span>, titleYOffset: <span style="color: #cc66cc;">4</span>, titleFont: <span style="color: #41ac44;">'Arial'</span>, titleSize: <span style="color: #cc66cc;">30</span>, titleColor: 0xffffff, titleAlign: <span style="color: #41ac44;">'LEFT'</span>, titleLeading: <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of properties defining menu tabs</span>
<span style="color: #000000; font-weight: bold;">var</span> tabProps:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
tabProps.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> tabXOffset: <span style="color: #cc66cc;">8</span>, tabYOffset: <span style="color: #cc66cc;">10</span>, tabFont: <span style="color: #41ac44;">'Arial'</span>, tabSize: <span style="color: #cc66cc;">18</span>, tabColor: 0xffffff, tabAlign: <span style="color: #41ac44;">'LEFT'</span>, tabSpacing: <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #000000; font-weight: bold;">var</span> menuID:uint = <span style="color: #cc66cc;">10</span>;
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>titles.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// create new instance of class</span>
	<span style="color: #000000; font-weight: bold;">var</span> d:DropDownMenus = <span style="color: #000000; font-weight: bold;">new</span> DropDownMenus<span style="color: #66cc66;">&#40;</span> menuID, titles<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>, bgWidth, bgHeight, bgColor, titleProps, tabs<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>, tabProps <span style="color: #66cc66;">&#41;</span>;
	d.<span style="color: #006600;">x</span> = xPos;
	d.<span style="color: #006600;">y</span> = yPos;
	d.<span style="color: #0066CC;">name</span> = <span style="color: #41ac44;">'d'</span> + i;
	d.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MenuTabSelected.<span style="color: #006600;">TAB_SELECTED</span>, onMenuTabSelected <span style="color: #66cc66;">&#41;</span>;
	addChild<span style="color: #66cc66;">&#40;</span> d <span style="color: #66cc66;">&#41;</span>;
&nbsp;
        <span style="color: #808080; font-style: italic;">// increment x position of next menu &amp; menu id number</span>
	xPos   += <span style="color: #66cc66;">&#40;</span> bgWidth + spacing <span style="color: #66cc66;">&#41;</span>;
	menuID += <span style="color: #cc66cc;">10</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// process selection</span>
<span style="color: #000000; font-weight: bold;">function</span> onMenuTabSelected<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MenuTabSelected <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #808080; font-style: italic;">// identify which menu and which submenu item have been selected</span>
	<span style="color: #000000; font-weight: bold;">var</span> menuID:uint = <span style="color: #0066CC;">Math</span>.<span style="color: #0066CC;">floor</span><span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">tabID</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">10</span> <span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">*</span> <span style="color: #cc66cc;">10</span>;
	<span style="color: #000000; font-weight: bold;">var</span> tabID:uint  = <span style="color: #0066CC;">e</span>.<span style="color: #006600;">tabID</span> - menuID;
	menuID = menuID <span style="color: #66cc66;">/</span> <span style="color: #cc66cc;">10</span>;
&nbsp;
	<span style="color: #808080; font-style: italic;">//trace( 'menu: ' + menuID + ' submenu: ' + tabID );</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

 <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=62" title=" downloaded 41 times" >DropDown2.zip (41)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=503</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using drop down menus:  the DropDownMenus class</title>
		<link>http://www.as3dtk.com/?p=500</link>
		<comments>http://www.as3dtk.com/?p=500#comments</comments>
		<pubDate>Thu, 08 Apr 2010 13:32:56 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[AS3 Custom Classes]]></category>
		<category><![CDATA[dropdown]]></category>
		<category><![CDATA[menus]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=500</guid>
		<description><![CDATA[In this post, the DropDownMenus class is introduced.&#160;&#160;The class may be used singularly &#8211; as shown &#8211; or as a group with a series of drop down menus placed side-by-side horizontally.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_dropDown_395236380"
			align="left"
			class="flashmovie"
			width="490"
			height="340">
	<param name="movie" value="swf/dropDown.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/dropDown.swf"
			name="fm_dropDown_395236380"
			align="left"
			width="490"
			height="340">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>

The sample code below shows three arrays passed to the class constructor to control all the text [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, the <strong>DropDownMenus</strong> class is introduced.&nbsp;&nbsp;The class may be used singularly &#8211; as shown &#8211; or as a group with a series of drop down menus placed side-by-side horizontally.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_dropDown_59410862"
			align="left"
			class="flashmovie"
			width="490"
			height="340">
	<param name="movie" value="swf/dropDown.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="swf/dropDown.swf"
			name="fm_dropDown_59410862"
			align="left"
			width="490"
			height="340">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><span id="more-500"></span></p>
<p>The sample code below shows three arrays passed to the class constructor to control all the text properties of both the menu&#8217;s main title and each of the menu&#8217;s subtitles.&nbsp;&nbsp;Each time a menu item is selected, the <em>onMenuTabSelected</em> is called by the class instance&#8217;s attached event listener.&nbsp;&nbsp;A switch statement is then used to direct the program to the proper function.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p50018"><td class="code" id="p500code18"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// import required classes</span>
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">DropDownMenus</span>;
<span style="color: #0066CC;">import</span> com.<span style="color: #006600;">dtk</span>.<span style="color: #006600;">MenuTabSelected</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// init vars to be passed to class instance</span>
<span style="color: #000000; font-weight: bold;">var</span> bgWidth:uint  = <span style="color: #cc66cc;">200</span>;
<span style="color: #000000; font-weight: bold;">var</span> bgHeight:uint = <span style="color: #cc66cc;">120</span>;
<span style="color: #000000; font-weight: bold;">var</span> bgColor:uint  = 0x1143d1;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of properties defining menu's main title</span>
<span style="color: #000000; font-weight: bold;">var</span> titleProps:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
titleProps.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> titleXOffset : <span style="color: #cc66cc;">2</span>, titleYOffset : <span style="color: #cc66cc;">4</span>, titleFont : <span style="color: #41ac44;">'Arial'</span>, titleSize : <span style="color: #cc66cc;">38</span>, titleColor : 0xffffff, titleAlign : <span style="color: #41ac44;">'LEFT'</span>, titleLeading : <span style="color: #cc66cc;">1</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// array of properties defining menu tabs</span>
<span style="color: #000000; font-weight: bold;">var</span> tabProps:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
tabProps.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> tabXOffset : <span style="color: #cc66cc;">4</span>, tabYOffset : <span style="color: #cc66cc;">20</span>, tabFont : <span style="color: #41ac44;">'Arial'</span>, tabSize : <span style="color: #cc66cc;">25</span>, tabColor : 0xffffff, tabAlign : <span style="color: #41ac44;">'LEFT'</span>, tabSpacing : <span style="color: #cc66cc;">7</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// main title of drop down</span>
<span style="color: #000000; font-weight: bold;">var</span> titleText:<span style="color: #0066CC;">String</span> = <span style="color: #41ac44;">'TV &amp; Video'</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// submenu - drop down - menu tabs</span>
<span style="color: #000000; font-weight: bold;">var</span> tabs:<span style="color: #0066CC;">Array</span> = <span style="color: #66cc66;">&#91;</span> <span style="color: #41ac44;">'Televisions'</span>, <span style="color: #41ac44;">'Projectors'</span>, <span style="color: #41ac44;">'BlueRay &amp; DVD'</span>, <span style="color: #41ac44;">'Home Theatre'</span>, <span style="color: #41ac44;">'TiVo'</span> <span style="color: #66cc66;">&#93;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// create new instance of class</span>
<span style="color: #000000; font-weight: bold;">var</span> dd:DropDownMenus = <span style="color: #000000; font-weight: bold;">new</span> DropDownMenus<span style="color: #66cc66;">&#40;</span> titleText, bgWidth, bgHeight, bgColor, titleProps, tabs, tabProps <span style="color: #66cc66;">&#41;</span>;
dd.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">10</span>;
dd.<span style="color: #006600;">y</span> =  <span style="color: #cc66cc;">0</span>;
dd.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span> MenuTabSelected.<span style="color: #006600;">TAB_SELECTED</span>, onMenuTabSelected <span style="color: #66cc66;">&#41;</span>;
addChild<span style="color: #66cc66;">&#40;</span> dd <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// process selection</span>
<span style="color: #000000; font-weight: bold;">function</span> onMenuTabSelected<span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>:MenuTabSelected <span style="color: #66cc66;">&#41;</span>:<span style="color: #0066CC;">void</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #b1b100;">switch</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #0066CC;">e</span>.<span style="color: #006600;">tabID</span> <span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">1</span>:
			<span style="color: #808080; font-style: italic;">// do tv </span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">2</span>:
			<span style="color: #808080; font-style: italic;">// do projector </span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">3</span>:
			<span style="color: #808080; font-style: italic;">// do tv </span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">4</span>:
			<span style="color: #808080; font-style: italic;">// do blueray </span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">5</span>:
			<span style="color: #808080; font-style: italic;">// do home theatre </span>
			<span style="color: #b1b100;">break</span>;
		<span style="color: #b1b100;">case</span> <span style="color: #cc66cc;">6</span>:
			<span style="color: #808080; font-style: italic;">// do home theatre </span>
			<span style="color: #b1b100;">break</span>;
	<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>The download includes the above .fla and the four class files required.&nbsp;&nbsp; <a class="downloadlink" href="http://www.as3dtk.com/wp-content/plugins/download-monitor/download.php?id=61" title=" downloaded 47 times" >DropDown.zip (47)</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=500</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting and combining arrays: sortOn( ) and concat( )</title>
		<link>http://www.as3dtk.com/?p=497</link>
		<comments>http://www.as3dtk.com/?p=497#comments</comments>
		<pubDate>Tue, 06 Apr 2010 14:30:15 +0000</pubDate>
		<dc:creator>Charles Davis</dc:creator>
				<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[caseinsensitive]]></category>
		<category><![CDATA[concat]]></category>
		<category><![CDATA[descending]]></category>
		<category><![CDATA[numeric]]></category>
		<category><![CDATA[sort]]></category>
		<category><![CDATA[sorton]]></category>
		<guid isPermaLink="false">http://www.as3dtk.com/?p=497</guid>
		<description><![CDATA[In this post, the sorting of indexed arrays using the sortOn method is discussed.&#160;&#160;Sorting options Array.CASEINSENSITIVE, DESCENDING and NUMERIC, are also defined.&#160;&#160;Finally, we&#8217;ll use concat to combine two arrays into a new array.&#160;&#160;

In the first example below, the array fruits is simply sorted by the field &#8216;name&#8217; and the results then displayed.

// array fruits
var fruits:Array [...]]]></description>
			<content:encoded><![CDATA[<p>In this post, the sorting of indexed arrays using the <em>sortOn</em> method is discussed.&nbsp;&nbsp;Sorting options <em>Array.CASEINSENSITIVE, DESCENDING and NUMERIC</em>, are also defined.&nbsp;&nbsp;Finally, we&#8217;ll use <em>concat</em> to combine two arrays into a new array.&nbsp;&nbsp;</p>
<p><span id="more-497"></span></p>
<p>In the first example below, the array <em>fruits</em> is simply sorted by the field &#8216;name&#8217; and the results then displayed.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p49723"><td class="code" id="p497code23"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// array fruits</span>
<span style="color: #000000; font-weight: bold;">var</span> fruits:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'apple'</span>,  price: <span style="color: #cc66cc;">2.29</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'orange'</span>, price: <span style="color: #cc66cc;">3.49</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'peach'</span>,  price: <span style="color: #cc66cc;">3.19</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'plum'</span>,   price: <span style="color: #cc66cc;">1.99</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sort by name</span>
fruits.<span style="color: #0066CC;">sortOn</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'name'</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// display sorted results</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>fruits.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">name</span> + <span style="color: #41ac44;">': '</span> + fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">price</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>In this next snippet, the same code is applied but the plum record is capitalized.&nbsp;&nbsp;When this is run, the first record in the resulting sort is now the Plum record because caps precede lower case.&nbsp;&nbsp;By adding the <em>Array.CASEINSENSITIVE</em> option, the array is sorted as expected.&nbsp;&nbsp;Comment out the original sortOn line, uncomment the line below with the option added and rerun.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p49724"><td class="code" id="p497code24"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// array fruits</span>
<span style="color: #000000; font-weight: bold;">var</span> fruits:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'apple'</span>,  price: <span style="color: #cc66cc;">2.29</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'orange'</span>, price: <span style="color: #cc66cc;">3.49</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'peach'</span>,  price: <span style="color: #cc66cc;">3.19</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'Plum'</span>,   price: <span style="color: #cc66cc;">1.99</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sort by name</span>
fruits.<span style="color: #0066CC;">sortOn</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'name'</span> <span style="color: #66cc66;">&#41;</span>; 
&nbsp;
<span style="color: #808080; font-style: italic;">// fruits.sortOn( 'name', Array.CASEINSENSITIVE );</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// display sorted results</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>fruits.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">name</span> + <span style="color: #41ac44;">': '</span> + fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">price</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>For the next example, the fruits array is sorted by price.&nbsp;&nbsp;Because numbers are sorted as if they were strings &#8211; 20 is greater than 1000 because 2 is grester than 1 &#8211; the <em>Array.NUMERIC</em> option is required to achieve proper results.&nbsp;&nbsp;To change the sort order to descending, a second option <em>Array.DESCENDING</em> is applied; it is separated from the first option by the bitwise operator (see commented out code below).</p>

<div class="wp_codebox"><table width="100%" ><tr id="p49725"><td class="code" id="p497code25"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// array fruits</span>
<span style="color: #000000; font-weight: bold;">var</span> fruits:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'apple'</span>,  price: <span style="color: #cc66cc;">2.29</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'orange'</span>, price: <span style="color: #cc66cc;">3.49</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'peach'</span>,  price: <span style="color: #cc66cc;">3.19</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'Plum'</span>,   price: <span style="color: #cc66cc;">1.99</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sort by price ascending (default)</span>
fruits.<span style="color: #0066CC;">sortOn</span><span style="color: #66cc66;">&#40;</span> <span style="color: #41ac44;">'price'</span>, <span style="color: #0066CC;">Array</span>.<span style="color: #006600;">NUMERIC</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sort by price descending</span>
<span style="color: #808080; font-style: italic;">// fruits.sortOn( 'price', Array.NUMERIC | Array.DESCENDING );</span>
&nbsp;
<span style="color: #808080; font-style: italic;">// display sorted results</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> i:uint=<span style="color: #cc66cc;">0</span>; i<span style="color: #66cc66;">&lt;</span>fruits.<span style="color: #0066CC;">length</span>; i++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">name</span> + <span style="color: #41ac44;">': '</span> + fruits<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">price</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>In this final example, a second array <em>vegies</em> is created.&nbsp;&nbsp;The concat( ) method is then used to combine the two arrays into a single new array named <em>foods</em>.&nbsp;&nbsp;The new array is then sorted on both the <em>cat</em> and then the <em>name</em> fields.&nbsp;&nbsp;Notice that by sorting on the <em>cat</em> field first the sort retains the grouping by <em>cat</em>.</p>

<div class="wp_codebox"><table width="100%" ><tr id="p49726"><td class="code" id="p497code26"><pre class="actionscript" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">var</span> fruits:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'apple'</span>,  price: <span style="color: #cc66cc;">2.29</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'orange'</span>, price: <span style="color: #cc66cc;">3.49</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'peach'</span>,  price: <span style="color: #cc66cc;">3.19</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
fruits.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'Plum'</span>,   price: <span style="color: #cc66cc;">1.99</span>, cat: <span style="color: #41ac44;">'fruit'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// new array vegies</span>
<span style="color: #000000; font-weight: bold;">var</span> vegies:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#41;</span>;
vegies.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'onion'</span>,     price: <span style="color: #cc66cc;">1.69</span>, cat: <span style="color: #41ac44;">'veg'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
vegies.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'lettuce'</span>,   price: <span style="color: #cc66cc;">2.39</span>, cat: <span style="color: #41ac44;">'veg'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
vegies.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'broccoli'</span>,  price: <span style="color: #cc66cc;">3.89</span>, cat: <span style="color: #41ac44;">'veg'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
vegies.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#123;</span> <span style="color: #0066CC;">name</span>: <span style="color: #41ac44;">'peas'</span>,      price: <span style="color: #cc66cc;">3.29</span>, cat: <span style="color: #41ac44;">'veg'</span> <span style="color: #66cc66;">&#125;</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// combine fruits &amp; vegies array into new array foods</span>
<span style="color: #000000; font-weight: bold;">var</span> foods:<span style="color: #0066CC;">Array</span> = fruits.<span style="color: #0066CC;">concat</span><span style="color: #66cc66;">&#40;</span> vegies <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// sort on fields cat first and name second with CASEINSENSITIVE option</span>
foods.<span style="color: #0066CC;">sortOn</span><span style="color: #66cc66;">&#40;</span> <span style="color: #66cc66;">&#91;</span><span style="color: #41ac44;">'cat'</span>, <span style="color: #41ac44;">'name'</span><span style="color: #66cc66;">&#93;</span>, <span style="color: #0066CC;">Array</span>.<span style="color: #006600;">CASEINSENSITIVE</span> <span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #808080; font-style: italic;">// display results</span>
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span> <span style="color: #000000; font-weight: bold;">var</span> j:uint=<span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&lt;</span>foods.<span style="color: #0066CC;">length</span>; j++ <span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span> foods<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #0066CC;">name</span> + <span style="color: #41ac44;">'  '</span> + foods<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">cat</span> + <span style="color: #41ac44;">': '</span> + foods<span style="color: #66cc66;">&#91;</span>j<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">price</span> <span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span></pre></td></tr></table></div>

<p>If this helped, consider a Retweet.  Thanks&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.as3dtk.com/?feed=rss2&amp;p=497</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
