<?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>manewc &#187; admin</title>
	<atom:link href="http://manewc.com/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://manewc.com</link>
	<description>iPhone, Flash, Flex, AIR, &#38; Web Development</description>
	<lastBuildDate>Sat, 31 Oct 2009 16:47:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>iPhone Aquarium Application: Aquaria FW</title>
		<link>http://manewc.com/2009/09/10/iphone-aquarium-application-aquaria-fw/</link>
		<comments>http://manewc.com/2009/09/10/iphone-aquarium-application-aquaria-fw/#comments</comments>
		<pubDate>Thu, 10 Sep 2009 20:41:26 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=292</guid>
		<description><![CDATA[With just under 2 weeks of the approval turn around process I am happy to see that my latest app has been approved and can be viewed here:
http://www.uiappview.com/aquaria-fw/
The app is Aquaria FW (Freshwater Fish) which is simply a spin off of the saltwater iphone aquarium maintenance application of Aquaria.
]]></description>
			<content:encoded><![CDATA[<p>With just under 2 weeks of the approval turn around process I am happy to see that my latest app has been approved and can be viewed here:</p>
<p><a href="http://www.uiappview.com/aquaria-fw/">http://www.uiappview.com/aquaria-fw/</a></p>
<p>The app is <strong>Aquaria FW (Freshwater Fish)</strong> which is simply a spin off of the saltwater iphone aquarium maintenance application of <a href="http://www.uiappview.com/aquaria/">Aquaria</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2009/09/10/iphone-aquarium-application-aquaria-fw/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Aquaria &#8211; iPhone Saltwater Aquarium Application</title>
		<link>http://manewc.com/2009/07/03/aquaria-iphone-saltwater-aqarium-application/</link>
		<comments>http://manewc.com/2009/07/03/aquaria-iphone-saltwater-aqarium-application/#comments</comments>
		<pubDate>Fri, 03 Jul 2009 17:02:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=283</guid>
		<description><![CDATA[
Well, after 2 weeks of being in review, my app Aquaria finally got approved. You can check out the details here:
http://www.uiappview.com/aquaria/
]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.uiappview.com/wp-content/uploads/2009/06/logo-aquaria.png" alt="Aquaria" /><br />
Well, after 2 weeks of being in review, my app Aquaria finally got approved. You can check out the details here:</p>
<p><a href="http://www.uiappview.com/aquaria/">http://www.uiappview.com/aquaria/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2009/07/03/aquaria-iphone-saltwater-aqarium-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iPhone Saltwater Fish Compatibility Chart Application</title>
		<link>http://manewc.com/2009/04/16/iphone-saltwater-fish-compatibility-application/</link>
		<comments>http://manewc.com/2009/04/16/iphone-saltwater-fish-compatibility-application/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 17:15:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=274</guid>
		<description><![CDATA[More details of the &#34;Aquaria&#34; application
Please Note: To clarify, this application was written in Objective-C and not in Flash Actionscript. (I noticed there was a forum thread linking to this page thinking this app was built in Actionscript)

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_fishCompatabilityVideo_1043217962"
			class="flashmovie"
			width="640"
			height="520">
	<param name="movie" value="/projects/iPhone/iFishCompatability/fishCompatabilityVideo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/iPhone/iFishCompatability/fishCompatabilityVideo.swf"
			name="fm_fishCompatabilityVideo_1043217962"
			width="640"
			height="520">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
One of my hobbies is maintaining my reef aquarium. I remember being at the [...]]]></description>
			<content:encoded><![CDATA[<p><strong><a href="http://www.uiappview.com/aquaria/">More details of the &quot;Aquaria&quot; application</a></strong></p>
<p><strong>Please Note: To clarify, this application was written in Objective-C and not in Flash Actionscript. (I noticed there was a forum thread linking to this page thinking this app was built in Actionscript)</strong></p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_fishCompatabilityVideo_606520905"
			class="flashmovie"
			width="640"
			height="520">
	<param name="movie" value="/projects/iPhone/iFishCompatability/fishCompatabilityVideo.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/iPhone/iFishCompatability/fishCompatabilityVideo.swf"
			name="fm_fishCompatabilityVideo_606520905"
			width="640"
			height="520">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>One of my hobbies is maintaining my reef aquarium. I remember being at the pet store wondering what impact a new fish would be to the current aquarium system. In my pursuit to learn more about building iPhone/iPod Touch applications and Objective-C I decided to build a simple application that would display the compatibility of one type of fish with another.</p>
<p>This project was interesting as it taught me more about the use of preference lists and being able to traverse the nodes of the .plist file. Here are some screenshots, and with some much needed testing on a real iPod Touch and iPhone I will soon push this to an app store. If by chance you are interested in saltwater aquariums and would like to help test this app, please let me know ( manewc [@] gmail )!</p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2009/04/16/iphone-saltwater-fish-compatibility-application/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>iPhone Laugh Track Application</title>
		<link>http://manewc.com/2009/04/13/iphone-laugh-track-application/</link>
		<comments>http://manewc.com/2009/04/13/iphone-laugh-track-application/#comments</comments>
		<pubDate>Mon, 13 Apr 2009 12:40:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=269</guid>
		<description><![CDATA[There are many laugh track applications for the iPhone or iPod touch &#8211; so I decided to make this custom simple application. My friend was looking for one that has specific audio tracks that he had.. so Nell&#233; here you go!

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_iLaugh_1874913110"
			class="flashmovie"
			width="640"
			height="520">
	<param name="movie" value="/projects/iPhone/iLaugh/iLaugh.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/iPhone/iLaugh/iLaugh.swf"
			name="fm_iLaugh_1874913110"
			width="640"
			height="520">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></description>
			<content:encoded><![CDATA[<p>There are many laugh track applications for the iPhone or iPod touch &#8211; so I decided to make this custom simple application. My friend was looking for one that has specific audio tracks that he had.. so <a href="http://www.scottnelle.com">Nell&eacute;</a> here you go!</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_iLaugh_1427639109"
			class="flashmovie"
			width="640"
			height="520">
	<param name="movie" value="/projects/iPhone/iLaugh/iLaugh.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/iPhone/iLaugh/iLaugh.swf"
			name="fm_iLaugh_1427639109"
			width="640"
			height="520">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2009/04/13/iphone-laugh-track-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AIR Screenshot Applications</title>
		<link>http://manewc.com/2009/01/12/air-screenshot-applications/</link>
		<comments>http://manewc.com/2009/01/12/air-screenshot-applications/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 18:39:11 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AIR]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=262</guid>
		<description><![CDATA[I know there are tons of AIR applications that will allow you to take a screenshot of a website, but I still wondered how this worked. Here is my first version, my only issue is that the image that is saved is only taking an image of what is visible within the viewable area. So, [...]]]></description>
			<content:encoded><![CDATA[<p>I know there are tons of AIR applications that will allow you to take a screenshot of a website, but I still wondered how this worked. Here is my first version, my only issue is that the image that is saved is only taking an image of what is visible within the viewable area. So, if the site&#8217;s bounds are larger than the application, then the image will get truncated&#8230; not sure what I need to do to fix this (scaling down?). Anyways, if any one knows I would be grateful for the help.</p>
<p>Here is my code:</p>
<p>&lt;?xml version=&#8221;1.0&#8243; encoding=&#8221;utf-8&#8243;?&gt;</p>
<p>&lt;mx:WindowedApplication xmlns:mx=&#8221;http://www.adobe.com/2006/mxml&#8221; layout=&#8221;absolute&#8221; width=&#8221;1024&#8243; height=&#8221;768&#8243;&gt;</p>
<p>&lt;mx:Script&gt;</p>
<p>&lt;![CDATA[</p>
<p>import mx.controls.Alert;</p>
<p>/*</p>
<p>For the Web Browser</p>
<p>*/</p>
<p>private function showWebPage(url:String):void</p>
<p>{</p>
<p>var siteurl:String = new String;</p>
<p>if ( url == "http://" )</p>
<p>{</p>
<p>siteurl = "http://www.google.com";</p>
<p>}</p>
<p>else if ( url.search("http://") &lt; 0)</p>
<p>{</p>
<p>siteurl = "http://" + url;</p>
<p>}</p>
<p>else</p>
<p>{</p>
<p>siteurl = url;</p>
<p>}</p>
<p>html.location = siteurl;</p>
<p>}</p>
<p>/*</p>
<p>For the Screen Capture</p>
<p>assistance: http://www.adobe.com/cfusion/communityengine/index.cfm?event=showdetails&amp;productId=2&amp;postId=8406</p>
<p>*/</p>
<p>import flash.display.BitmapData;</p>
<p>import mx.graphics.codec.JPEGEncoder; // encode to jpeg</p>
<p>private function openDialogue():void</p>
<p>{</p>
<p>var docsDir:File = File.documentsDirectory;</p>
<p>var f:File = new File( "/.jpg" );</p>
<p>try{</p>
<p>f.browseForSave("Save As");</p>
<p>f.addEventListener(Event.SELECT, saveData);</p>
<p>}</p>
<p>catch(e:Error)</p>
<p>{</p>
<p>trace(e.message);</p>
<p>}</p>
<p>}</p>
<p>private function saveData (e:Event):void</p>
<p>{</p>
<p>// take the snapshot</p>
<p>var bmpd:BitmapData = new BitmapData ( html.contentWidth, html.contentHeight );</p>
<p>// draw method public function draw(source, matrix, colorTransform, blendMode, clipRect, smoothing:Boolean = false</p>
<p>var drawRect:Rectangle = new Rectangle ( 0, 0, html.contentWidth, html.contentHeight );</p>
<p>bmpd.draw ( html,null,null,null,drawRect,false );</p>
<p>// encode bitmap data object to bytearray object so</p>
<p>// we can save it to a file</p>
<p>var jpgenc:JPEGEncoder = new JPEGEncoder(80); // 80 compression level</p>
<p>// encode the object</p>
<p>var imgba:ByteArray = jpgenc.encode( bmpd );</p>
<p>// now save it</p>
<p>//gets a reference to a new empty jpg image file in user desktop</p>
<p>var fl:File = e.target as File;</p>
<p>if (!fl.exists)</p>
<p>{</p>
<p>var stream:FileStream = new FileStream();</p>
<p>stream.open(fl, FileMode.WRITE);</p>
<p>stream.writeBytes(imgba);</p>
<p>stream.close();</p>
<p>}</p>
<p>}</p>
<p>]]&gt;</p>
<p>&lt;/mx:Script&gt;</p>
<p>&lt;mx:HTML width=&#8221;100%&#8221; height=&#8221;100%&#8221; id=&#8221;html&#8221; x=&#8221;0&#8243; y=&#8221;40&#8243;/&gt;</p>
<p>&lt;mx:TextInput x=&#8221;10&#8243; y=&#8221;12&#8243; text=&#8221;http://&#8221; width=&#8221;443&#8243; id=&#8221;urlPage&#8221; /&gt;</p>
<p>&lt;mx:Button x=&#8221;461&#8243; y=&#8221;10&#8243; label=&#8221;Go!&#8221; click=&#8221;showWebPage(urlPage.text)&#8221;/&gt;</p>
<p>&lt;mx:Button x=&#8221;705&#8243; y=&#8221;10&#8243; label=&#8221;Save Screen Capture&#8221; click=&#8221;openDialogue()&#8221;/&gt;</p>
<p>&lt;/mx:WindowedApplication&gt;</p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2009/01/12/air-screenshot-applications/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Downloading Multiple Files with Flex 3 and AMFPHP</title>
		<link>http://manewc.com/2008/12/22/downloading-multiple-files-with-flex-3/</link>
		<comments>http://manewc.com/2008/12/22/downloading-multiple-files-with-flex-3/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 16:44:52 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[AMFPHP]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Flex Web Development]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=254</guid>
		<description><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Main_1450049973"
			class="flashmovie"
			width="700"
			height="540">
	<param name="movie" value="/projects/flex3/MultipleFileDownloadAMFPHP/Main.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flex3/MultipleFileDownloadAMFPHP/Main.swf"
			name="fm_Main_1450049973"
			width="700"
			height="540">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
I originally was thinking that I would be able to do this by having the user select the files of their choice and click one button to download the items. So depending on their selection the Flex app would download the first item, then upon complete download of the first item [...]]]></description>
			<content:encoded><![CDATA[
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_Main_1342573712"
			class="flashmovie"
			width="700"
			height="540">
	<param name="movie" value="/projects/flex3/MultipleFileDownloadAMFPHP/Main.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flex3/MultipleFileDownloadAMFPHP/Main.swf"
			name="fm_Main_1342573712"
			width="700"
			height="540">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I originally was thinking that I would be able to do this by having the user select the files of their choice and click one button to download the items. So depending on their selection the Flex app would download the first item, then upon complete download of the first item it would download the second item and so on.. Unfortunately I could not get this to work on various browsers as the dialog box to download the file location would never appear on the second file. So with a little exploring I was able to accomplish the task of downloading multiple files of the users choosing with the use of:</p>
<p>Here is a list of things that I needed to get this working.</p>
<ol>
<li><a href="http://www.amfphp.org">AMFPHP</a> &#8211; Lee Brimelow has an excellent tutorial to get you started: <a href="http://www.gotoandlearn.com/play?id=78">http://www.gotoandlearn.com/play?id=78</a></li>
<li>PHP Class file to create zip documents from an array. You can find the one I used here: <a href="http://www.phpconcept.net/pclzip/index.en.php">http://www.phpconcept.net/pclzip/index.en.php</a> (note I am using PHP 5.*)</li>
<li>I also grabbed this class file from <a href="http://www.flexexamples.com">FlexExamples.com</a> for <a href="http://blog.flexexamples.com/2008/01/27/using-a-checkbox-control-as-a-list-item-renderer-in-flex/">using a checkbox control as a list item renderer</a></li>
</ol>
<p>Here is the process:</p>
<ol>
<li>So first the user will select the files he/she wishes to download</li>
<li>The user will need to click a button to notify the server the array of files and generate a unique .zip document</li>
<li>The download button will need to be active once the zip file is created so the user can then download the new .zip file</li>
<li>User clicks the download button to download the file</li>
<li>Will need to run a cron to delete all the generated .zip files as to not load up my server. (I won&#8217;t cover this step)</li>
</ol>
<p>Honestly I am not a PHP programmer, but this is the Service Class that I put in my Service folder in my AMFPHP setup&#8230;</p>
<p>The file name is ZipFile.php (also don&#8217;t forget to inlude the library for zipping files)</p>
<pre name="code" class="c-sharp">
&lt;?php

class ZipFile
{
	/**
	* Demo ZipFile
	* @returns file name of zip object
	*/

	function ZipFileTest($fileArr) // this is what gets called from flash
	{
		// include the library from http://www.phpconcept.net/pclzip/index.en.php
		include_once("pclzip.lib.php");

		// create a unique file name.. this is prepended with manewc.com-
		$uniqueFileName = uniqid("manewc.com-");

		// create the zip
		$archive = new PclZip('../relative/path/to/put/this/zip/file'.$uniqueFileName.'.zip');

		$v_list = $archive->create($fileArr);

  		if ($v_list == 0) {
    		$status = "Error : ".$archive->errorInfo(true);
  		}
  		else
  		{
  			$status = $uniqueFileName;
  		}

		return $status;

	}
}

?$gt;
</pre>
<p>In Flex, I just need to add the ListItemValueObject.as file from <a href="http://blog.flexexamples.com/2008/01/27/using-a-checkbox-control-as-a-list-item-renderer-in-flex/">FlexExamples.com</a>. I added this file in src/com/flexexamples/.</p>
<p>Here is my Main.mxml file to create the ui:</p>
<p><strong>Please note that my editor generally does not render my flex code properly.. check this file here: <a href="http://manewc.com/projects/flex3/MultipleFileDownloadAMFPHP/Main.mxml.txt">Main.mxml.txt</a></strong></p>
<pre name="code" class="c-sharp">
<?xml version="1.0" encoding="utf-8"?>
<mx:Application
    xmlns:mx="http://www.adobe.com/2006/mxml"
    xmlns:vo="com.flexexamples.*"
    layout="absolute"
    creationComplete="init()">

    <mx:Script>
        <![CDATA[
            import mx.controls.Alert;
            import flash.net.FileReference;
            import com.flexexamples.*;

            import mx.events.CollectionEvent;
            import mx.utils.ObjectUtil;

            private var phpArr:String = "";
            private var tArr:Array;

            public var DOWNLOAD_URL:String;
            public var _fr:FileReference = new FileReference();
            // private var _dlFileName:String;

            private function init():void {
                arrColl.dispatchEvent(new CollectionEvent(CollectionEvent.COLLECTION_CHANGE));
            }

            private function arrColl_collectionChange(evt:CollectionEvent):void {
                try {
                    tArr = arrColl.source.filter(selectedOnly);
                    textArea.text = ObjectUtil.toString(tArr);
                    lbl.text = tArr.length.toString() + " item(s) selected";
                } catch (err:Error) {
                    // ignore.
                }
            }

            private function selectedOnly(item:ListItemValueObject, idx:uint, arr:Array):Boolean {
                return item.isSelected;
            }

            private function amfphp():void
            {
                // create the array of files:
                // var filesToDL:Array = new Array("../../projects/flex3/FileDownloadMultiple/life-1.jpg","../../projects/flex3/FileDownloadMultiple/life-2.jpg");

                var filesToDL:Array = new Array();
                for ( var k:int=0; k < tArr.length; k++ )
                {
                    filesToDL[k] = tArr[k].fileLocation;
                }

                // mx.controls.Alert.show ( "Item: " + filesToDL );

                // reconfigure Array so PHP can interpret
                phpArr = "";
                for ( var u:int=0; u < filesToDL.length; u++ )
                {
                    phpArr += filesToDL[u];

                    if ( u < filesToDL.length - 1 )
                    {
                        phpArr += ",";
                    }
                }

                txtOutput.htmlText = "Waiting for status...\n" + phpArr + " (" + filesToDL.length + " items)\n";

                //connect
                var gw:NetConnection = new NetConnection();
                gw.connect( "../../../amfphp/gateway.php" );

                // 2 functions called when data is passed back..
                // one for success, one for failure
                var res:Responder = new Responder ( onResult, onFault );

                // the php method, the result, parameters
                gw.call ( "ZipFile.ZipFileTest", res, phpArr);

            }

            private function onResult ( responds:Object ):void
            {
                txtOutput.htmlText = "File to download: " + responds;

                // file to download name:
                DOWNLOAD_URL = responds as String;

                // all set, now activate the download file button
                btnDownload.enabled = true;
            }

            private function onFault ( responds:Object):void
            {
                for ( var i in responds )
                {
                    txtOutput.htmlText = "Error: " + responds[i];
                }
            }

            private function downloadFile():void
            {
                // disable the download button
                btnDownload.enabled = false;

                // mx.controls.Alert.show( "test" + DOWNLOAD_URL );
                _fr = new FileReference;
                _fr.addEventListener(Event.OPEN, openHandler);
                _fr.addEventListener(ProgressEvent.PROGRESS, progressHandler);
                _fr.addEventListener(Event.COMPLETE, completeHandler);

                // DOWNLOAD_URL = "http://manewc.com/projects/download/archive.zip";
                if ( DOWNLOAD_URL != "" )
                {
                    // DOWNLOAD_URL = "";
                }

                DOWNLOAD_URL = "../../download/" + DOWNLOAD_URL + ".zip";
                 txtOutput.htmlText = "DLURL: " + DOWNLOAD_URL;

                var request:URLRequest = new URLRequest();
                request.url = DOWNLOAD_URL;
                _fr.download(request);
            }

            /**
         * When the OPEN event has dispatched, change the progress bar's label
         * and enable the "Cancel" button, which allows the user to abort the
         * download operation.
         */
        private function openHandler(event:Event):void {
            pb.label = "DOWNLOADING %3%%";
            txtOutput.htmlText = "DOWNLOADING %3%%";
        }

        /**
         * While the file is downloading, update the progress bar's status and label.
         */
        private function progressHandler(event:ProgressEvent):void {
            pb.setProgress(event.bytesLoaded, event.bytesTotal);
            txtOutput.htmlText = "DOWNLOADING... " + (event.bytesLoaded/event.bytesTotal) + "%";
        }

        /**
         * Once the download has completed, change the progress bar's label and
         * disable the "Cancel" button since the download is already completed.
         */
        private function completeHandler(event:Event):void {
            // loadedStatus = true;
               pb.label = "DOWNLOAD COMPLETE";
            pb.setProgress(0, 100);
            //btn.enabled = false;
            txtOutput.htmlText = "DOWNLOADING... COMPLETE"

        }
        ]]&gt;
    </mx:Script>
    <mx:Text id="txtOutput" x="261.5" y="40" width="366.5"/>
    <mx:Button x="261.5" y="10" label="Download File" click="downloadFile()" enabled="false" id="btnDownload"/>

    <mx:Panel title="Download File Progress" paddingTop="10" paddingBottom="10" paddingLeft="10" paddingRight="10" x="261.5" y="68">
    <mx:ProgressBar id="pb" label="progress" mode="manual" />
    </mx:Panel>

    <mx:Array id="arr">
        <vo:ListItemValueObject label="Flash Files" isSelected="true" fileLocation="../../projects/flash/PapervisionCubeSides/PapervisionCubeSides.zip" />
        <vo:ListItemValueObject label="Image One" isSelected="true" fileLocation="../../projects/flex3/FileDownloadMultiple/life-1.jpg" />
        <vo:ListItemValueObject label="Image Two" isSelected="true" fileLocation="../../projects/flex3/FileDownloadMultiple/life-2.jpg" />
    </mx:Array>

    <mx:ArrayCollection id="arrColl"
            source="{arr}"
            collectionChange="arrColl_collectionChange(event);" />

    <mx:Panel id="panel"
            title="Items"
            status="{arrColl.length} total"
            styleName="opaquePanel" x="10" y="10">
        <mx:List id="list"
                dataProvider="{arrColl}"
                alternatingItemColors="[#cccccc, #ffffff]"
                width="150"
                rowCount="8">
            <mx:itemRenderer>
                <mx:Component>
                    <mx:CheckBox selectedField="isSelected"
                            change="onChange(event);">
                        <mx:Script>
                            <![CDATA[
                                private function onChange(evt:Event):void {
                                    data.isSelected = !data.isSelected;
                                }
                            ]]&gt;
                        </mx:Script>
                    </mx:CheckBox>
                </mx:Component>
            </mx:itemRenderer>
        </mx:List>
        <mx:Label id="lbl" />
        <mx:ControlBar horizontalAlign="right" height="40">
            <mx:Button id="btnRun" label="Zip Files" click="amfphp()"/>
        </mx:ControlBar>
    </mx:Panel>

    <mx:TextArea id="textArea"
            verticalScrollPolicy="on"
            width="366.5"
            height="{panel.height}"  x="261.5" y="177"/>

</mx:Application>
</pre>
<p>I&#8217;ll have to admit that this code needs to be cleaned up.. just ran out of time at the moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/22/downloading-multiple-files-with-flex-3/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Collision Within A Circle</title>
		<link>http://manewc.com/2008/12/12/ape-collision-within-a-circle/</link>
		<comments>http://manewc.com/2008/12/12/ape-collision-within-a-circle/#comments</comments>
		<pubDate>Fri, 12 Dec 2008 18:18:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=248</guid>
		<description><![CDATA[A slight modification that adds a CircleParticle with constant motion inside of the circle.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_1802402786"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_1802402786"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
The Main.as Document Class:

package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;

		private var c:Circle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos [...]]]></description>
			<content:encoded><![CDATA[<p>A slight modification that adds a CircleParticle with constant motion inside of the circle.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_2037122406"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle2/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_2037122406"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The Main.as Document Class:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;

		private var c:Circle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos ( vr );
		private var sin:Number = Math.sin ( vr );

		private var _ct:Number = 0; // counter

		private var _ptarr:Array = new Array();
		private var defaultGroup:Group;
		private var _scarr:Array = new Array();

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			//APEngine.addMasslessForce(new Vector(0,6));
			APEngine.addMasslessForce(new Vector(0,0));

			defaultGroup = new Group();

			defaultGroup.collideInternal = true;

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);

			follow = new Ball();
			addChild ( follow );
			follow.x = 130;
			follow.y = 130;
			follow.addEventListener ( Event.ENTER_FRAME, drawCircleBounds );
		}

		private function drawCircleBounds (e:Event):void
		{
			var x1:Number = follow.x - stage.stageWidth / 2;
			var y1:Number = follow.y - stage.stageHeight / 2;
			var x2:Number = cos * x1 - sin * y1;
			var y2:Number = cos * y1 + sin * x1;

			follow.x = stage.stageWidth / 2 + x2;
			follow.y = stage.stageHeight / 2 + y2;

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* Points of Circle
			------------------
			*/
			_ptarr[_ct] = new CircleParticle(follow.x, follow.y, 2, true, 1, 0);
           	_ptarr[_ct].setStyle(0, 0, 0, 0xffffff);
			defaultGroup.addParticle(_ptarr[_ct]);

			/* Connectors
			------------------
			*/

			if ( _ct > 0 )
			{
				_scarr[_ct] = new SpringConstraint(_ptarr[_ct-1], _ptarr[_ct], 4, true);
				defaultGroup.addConstraint( _scarr[_ct] );

				if ( _ct >= _maxpts )
				{
					_scarr[_ct+1] = new SpringConstraint(_ptarr[_ct], _ptarr[0], 4, true);
					defaultGroup.addConstraint( _scarr[_ct+1] );

					dropBall();
				}
			}

			/* Update
			------------------
			*/
			_ct++;

			/* Check end
			------------------
			*/
			if ( _ct > _maxpts ) follow.removeEventListener ( Event.ENTER_FRAME, drawCircleBounds );

		}

		private function dropBall():void
		{
			c = new Circle ( stage.stageWidth / 2, stage.stageHeight / 2, 30 );
			APEngine.addGroup(c);
			c.addCollidable ( defaultGroup );

			// make the ball move
			c.cp.velocity = (new Vector(10, 10));
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

	}
}
</pre>
<p>The Circle.as class</p>
<pre name="code" class="c-sharp">
package
{
	import org.cove.ape.Group;
	import org.cove.ape.CircleParticle;
	import org.cove.ape.Vector;

	public class Circle extends Group
	{
		public var cp:CircleParticle;

		/*
		x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
		*/

		public function Circle(x:uint, y:uint, r:Number=5, c:uint = 0xffffff)
		{
			cp = new CircleParticle(x, y, r, false, 1, 1);
			cp.setStyle(0, 0, 0, c);
			addParticle(cp);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/12/ape-collision-within-a-circle/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Animation within Circular Bounds</title>
		<link>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/</link>
		<comments>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 18:47:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=242</guid>
		<description><![CDATA[Here is a little movie that will generate a circle and then place a dragable circle particle contained within it&#8217;s circular bounds. I unfortunately have run out of time for today to clean up this file, so I will consider this as part 1. Note, if you interact with this movie, the key is to [...]]]></description>
			<content:encoded><![CDATA[<p>Here is a little movie that will generate a circle and then place a dragable circle particle contained within it&#8217;s circular bounds. I unfortunately have run out of time for today to clean up this file, so I will consider this as part 1. Note, if you interact with this movie, the key is to &#8216;gently&#8217; toss the circle against the walls, else the circle will fly off of the screen <img src='http://manewc.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_CollisionInsideCircle_1877757591"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APECollisionInsideCircle/CollisionInsideCircle.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APECollisionInsideCircle/CollisionInsideCircle.swf"
			name="fm_CollisionInsideCircle_1877757591"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the Main.as file:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import org.cove.ape.*;

	public class Main extends Sprite
	{
		private var follow:Ball;
		private var db:DragableCircleParticle;
		private var vr:Number = .4;
		private var _maxpts:Number = 15; // number of drawn points, this is dependent on vr variable.
		private var cos:Number = Math.cos ( vr );
		private var sin:Number = Math.sin ( vr );

		private var _ct:Number = 0; // counter

		private var _ptarr:Array = new Array();
		private var defaultGroup:Group;
		private var _scarr:Array = new Array();

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			APEngine.addMasslessForce(new Vector(0,6));

			defaultGroup = new Group();

			defaultGroup.collideInternal = true;

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);

			follow = new Ball();
			addChild ( follow );
			follow.x = 130;
			follow.y = 130;
			follow.addEventListener ( Event.ENTER_FRAME, drawCircleBounds );
		}

		private function drawCircleBounds (e:Event):void
		{
			var x1:Number = follow.x - stage.stageWidth / 2;
			var y1:Number = follow.y - stage.stageHeight / 2;
			var x2:Number = cos * x1 - sin * y1;
			var y2:Number = cos * y1 + sin * x1;

			follow.x = stage.stageWidth / 2 + x2;
			follow.y = stage.stageHeight / 2 + y2;

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* Points of Circle
			------------------
			*/
			_ptarr[_ct] = new CircleParticle(follow.x, follow.y, 2, true, 1, 0);
           	_ptarr[_ct].setStyle(0, 0, 0, 0xffffff);
			defaultGroup.addParticle(_ptarr[_ct]);

			/* Connectors
			------------------
			*/

			if ( _ct > 0 )
			{
				_scarr[_ct] = new SpringConstraint(_ptarr[_ct-1], _ptarr[_ct], 4, true);
				defaultGroup.addConstraint( _scarr[_ct] );

				if ( _ct >= _maxpts )
				{
					_scarr[_ct+1] = new SpringConstraint(_ptarr[_ct], _ptarr[0], 4, true);
					defaultGroup.addConstraint( _scarr[_ct+1] );

					dropBall();
				}
			}

			/* Update
			------------------
			*/
			_ct++;

			/* Check end
			------------------
			*/
			if ( _ct > _maxpts ) follow.removeEventListener ( Event.ENTER_FRAME, drawCircleBounds );

		}

		private function dropBall():void
		{
			db = new DragableCircleParticle(160, 150, 30, false, 10, .3);
			db.setStyle(0, 0, 0, 0x993300);
			defaultGroup.addParticle(db);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}

	}
}
</pre>
<p>and the Ball.as file ( this is used as the red ball )</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;

	public class Ball extends Sprite {
		public var radius:Number;
		private var color:uint;
		public var xpos:Number = 0;
		public var ypos:Number = 0;
		public var zpos:Number = 0;
		public var vx:Number = 0;
		public var vy:Number = 0;
		public var vz:Number = 0;
		public var mass:Number = 1;

		public function Ball(radius:Number=10, color:uint=0xff0000) {
			this.radius = radius;
			this.color = color;
			init();
		}
		public function init():void {
			graphics.lineStyle(0);
			graphics.beginFill(color);
			graphics.drawCircle(0, 0, radius);
			graphics.endFill();
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/10/ape-animation-within-circular-bounds/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Image Gallery &#8211; Part VI &#8211; Active Image</title>
		<link>http://manewc.com/2008/12/09/image-gallery-part-vi-active-image/</link>
		<comments>http://manewc.com/2008/12/09/image-gallery-part-vi-active-image/#comments</comments>
		<pubDate>Tue, 09 Dec 2008 18:20:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Actionscript XML]]></category>
		<category><![CDATA[Image Gallery Project]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=240</guid>
		<description><![CDATA[I updated 2 files: ImageGallery.as and Thumbnail.as to allow for the display of the first large image (or any other image you assign as the CurrentIndex variable) in the xml file and to display an active/inactive state for the thumbnail images:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageGallery_1874311885"
			class="flashmovie"
			width="700"
			height="750">
	<param name="movie" value="/projects/flash/ImageGallery6/ImageGallery.swf" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ImageGallery6/ImageGallery.swf"
			name="fm_ImageGallery_1874311885"
			width="700"
			height="750">
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
I will be the first to admit that these files [...]]]></description>
			<content:encoded><![CDATA[<p>I updated 2 files: ImageGallery.as and Thumbnail.as to allow for the display of the first large image (or any other image you assign as the CurrentIndex variable) in the xml file and to display an active/inactive state for the thumbnail images:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageGallery_428848786"
			class="flashmovie"
			width="700"
			height="750">
	<param name="movie" value="/projects/flash/ImageGallery6/ImageGallery.swf" />
	<param name="allowfullscreen" value="true" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ImageGallery6/ImageGallery.swf"
			name="fm_ImageGallery_428848786"
			width="700"
			height="750">
		<param name="allowfullscreen" value="true" />
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p><strong>I will be the first to admit that these files need to be cleaned up and properly coded.. but this will be a good base for a clean future project.</strong></p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.display.Shape;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import caurina.transitions.*;

	public class ImageGallery extends Sprite
	{
		private var ThumbArray:Array;
		private var tobj:Array; // thumb object array
		private var thumbMargin:Number = 5;
		private var ThumbNavigation:Sprite; // this is to hold all the thumbnails
		private var incrementArr:Array;
		private var VisibleThumbnails:Number = 4; // this will set the number of thumbnails that will be visible.
		private var MaskWidth:Number;
		private var myMask:Shape;
		private var maskHeight:Number = 100;
		private var nb:Sprite;
		private var bb:Sprite;
		private var nbs:Shape; // next button
		private var bbs:Shape; // back button
		private var CurrentIndex:Number = 0;
		private var ButtonIndex:Number;
		private var ButtonCounter:Number = 0;
		private var beginPoint:Number;
		private var endPoint:Number;
		private var destPoint:Number;
		private var ThumbNavigationOffset:Number;
		private var MainImage:LargeImage;
		private var MainImageMask:Shape;

		public function ImageGallery(iarr:Array)
		{
			// the array of the thumbnail images
			ThumbArray = new Array();

			for ( var g:uint = 0; g < iarr.length; g++ )
			{
				ThumbArray[g] = new Array ( iarr[g][0], iarr[g][1] );
			}

			addEventListener ( Event.ADDED_TO_STAGE, init );

			ButtonIndex = VisibleThumbnails;
		}

		private function init(e:Event):void
		{
			// the holder movie to hold all the thumbnail images
			ThumbNavigation = new Sprite();
			addChild ( ThumbNavigation );
			// put it off the stage
			ThumbNavigation.y = stage.stageHeight + maskHeight;

			// create the thumbnails
			tobj = new Array;

			for ( var c:uint = 0; c < ThumbArray.length; c++ )
			{
				// create a thumbnail image
				tobj.push ( new Thumbnail( ThumbArray[c][0], c ) );
			}

			// set the event to make sure all images are loaded
			addEventListener ( Event.ENTER_FRAME, checkLoadedThumb );

			// THIS IS WHERE WE WILL SET THE DEFAULT LARGE IMAGE
			DisplayLargeImage ( CurrentIndex ); // display the large image
		}

		private function checkLoadedThumb ( e:Event ):void
		{
			var loadCounter:Number = 0;

			for ( var d:uint = 0; d < ThumbArray.length; d++ )
			{
				if ( tobj[d].myWidth > 0 )
				{
					loadCounter++;
				}
			}

			if ( loadCounter == ThumbArray.length )
			{
				removeEventListener ( Event.ENTER_FRAME, checkLoadedThumb );

				// position the thumbnails
				positionThumbs();
			}
		}

		private function positionThumbs():void
		{
			var totalWidth:Number = 0;
			incrementArr = new Array();

			for ( var v:uint = 0; v < ThumbArray.length; v++ )
			{
				tobj[v].x = totalWidth;
				tobj[v].alpha = 0;

				// set the increments for each slide position when moving left to right
				incrementArr.push ( totalWidth );

				trace ( incrementArr[v] );
				// check for the width of the mask to go over thumbnail navigation
				if ( v == VisibleThumbnails )
				{
					MaskWidth = totalWidth;

					// create the mask
					CreateThumbnailMask();
				}

				totalWidth += thumbMargin + tobj[v].myWidth;
				// add the thumbnail to the stage
				ThumbNavigation.addChild ( tobj[v] );

				// thumbnail is alpha 0, let's fade it up to 80%
				Tweener.addTween(tobj[v], {alpha: .8, time:.8, transition:"easeOut"});

				// add the mouseevents
				tobj[v].addEventListener ( MouseEvent.MOUSE_OVER, ThumbOver );
				tobj[v].addEventListener ( MouseEvent.MOUSE_DOWN, ThumbDown );
				tobj[v].addEventListener ( MouseEvent.MOUSE_OUT, ThumbOut );
			}

			// show the active state of the thumbnail:
			tobj[CurrentIndex].activeState(); // set the look of the active thumbnail
		}

		private function CreateThumbnailMask():void
		{
			// Center the Menu
			ThumbNavigation.x = (stage.stageWidth / 2) - (MaskWidth / 2);
			ThumbNavigationOffset = ThumbNavigation.x;

			// Create the Mask
			myMask = new Shape();
            myMask.graphics.beginFill(0x000000);
            myMask.graphics.drawRect(ThumbNavigation.x, stage.stageHeight-maskHeight, MaskWidth, maskHeight);
            myMask.graphics.endFill();

			addChild ( myMask );

			// set the mask
			ThumbNavigation.mask = myMask;

			// show the Menu on Y axis
			Tweener.addTween(ThumbNavigation,{y:stage.stageHeight-maskHeight, time:.5, transition:"easeOut"});

			// create the next button
			NextButton();

			// create the back button
			BackButton();

			// setupUI;
			SetupUI();
		}

		private function ThumbOver (m:MouseEvent):void
		{
			if ( !m.currentTarget.getState() )
			{
				Tweener.addTween(m.currentTarget, {alpha: 1, time:.8, transition:"easeOutBack"});
				Tweener.addTween(m.currentTarget, {y: -20, time:2, transition:"easeOut"});
			}
		}

		private function DisplayLargeImage (n:int):void
		{
			if ( MainImage ) removeChild ( MainImage );

			MainImage = new LargeImage ( ThumbArray[n][1] );
			addChildAt ( MainImage, 0 );

			// Create the Main Image Mask
			MainImageMask = new Shape();
            MainImageMask.graphics.beginFill(0x000000);
            MainImageMask.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight-maskHeight-10);
            MainImageMask.graphics.endFill();
			addChild ( MainImageMask );

			MainImage.mask = MainImageMask;
		}

		private function ThumbDown (m:MouseEvent):void
		{
			if ( !m.currentTarget.getState() )
			{
				// display the default State of the previous selected thumbnail
				tobj[CurrentIndex].defaultState();

				// re initialize the index value
				CurrentIndex = m.currentTarget.myId;

				// display the active state
				m.currentTarget.activeState();

				DisplayLargeImage ( CurrentIndex );
			}
		}

		private function ThumbOut (m:MouseEvent):void
		{
			if ( !m.currentTarget.getState() ) Tweener.addTween(m.currentTarget, {alpha: .8, time:2, transition:"easeOutBack"});

			Tweener.addTween(m.currentTarget, {y: 0, time:2, transition:"easeOut"});
		}

		private function NextButton():void
		{
			nbs = new Shape();
            nbs.graphics.beginFill(0x000000);
            nbs.graphics.drawRect(stage.stageWidth - 20, stage.stageHeight-maskHeight, 20, maskHeight);
            nbs.graphics.endFill();

			nb = new Sprite();
			nb.name = "nextbutton";
			addChild ( nb );

			nb.addChild ( nbs );

			nb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
		}

		private function BackButton():void
		{
			bbs = new Shape();
            bbs.graphics.beginFill(0x000000);
            //myMask.graphics.lineStyle(1, 0x000000);
            bbs.graphics.drawRect(0, stage.stageHeight-maskHeight, 20, maskHeight);
            bbs.graphics.endFill();

			bb = new Sprite();
			addChild ( bb );
			bb.name = "backbutton";
			bb.addChild ( bbs );

			bb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
		}

		private function MoveThumbnails(m:MouseEvent):void
		{
			// check the current index and slide accordingly
			if ( m.currentTarget.name == "nextbutton" &#038;&#038; ButtonIndex < ThumbArray.length )
			{
				nb.removeEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );

				ButtonIndex++;

				destPoint = ThumbNavigationOffset - incrementArr[++ButtonCounter];

				Tweener.addTween(ThumbNavigation,{x:destPoint, time:.6, transition:"easeOut", onComplete:EnableButtons("nextbutton")});
			}
			else if ( m.currentTarget.name == "backbutton" &#038;&#038; ButtonIndex > 0 )
			{
				bb.removeEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );

				ButtonIndex--;

				destPoint = ThumbNavigationOffset - incrementArr[--ButtonCounter];
				Tweener.addTween(ThumbNavigation,{x:destPoint, time:.5, transition:"easeOut", onComplete:EnableButtons("backbutton")});
			}

			SetupUI();
		}

		private function EnableButtons(btnId:String):void
		{
			if ( btnId == "nextbutton" ) nb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
			if ( btnId == "backbutton" ) bb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
		}

		private function SetupUI():void
		{
			// this function is to control the visibility of the next and back buttons
			trace ( "ButtonIndex: " + ButtonIndex + " " + VisibleThumbnails );
			if ( ButtonIndex > VisibleThumbnails )
			{
				Tweener.addTween(bb, {alpha: 1, time:2, transition:"easeOut"});
				// Tweener.addTween(nb, {alpha: 1, time:2, transition:"easeOut"});
				bb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
			}
			else if ( ButtonIndex == VisibleThumbnails )
			{
				Tweener.addTween(bb, {alpha: 0, time:2, transition:"easeOut"});
				bb.removeEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
			}

			if ( ButtonIndex == ThumbArray.length )
			{
				Tweener.addTween(nb, {alpha: 0, time:2, transition:"easeOut"});
				nb.removeEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
			}
			else
			{
				Tweener.addTween(nb, {alpha: 1, time:2, transition:"easeOut"});
				nb.addEventListener( MouseEvent.MOUSE_DOWN, MoveThumbnails );
			}
		}
	}
}
</pre>
<p>and the Thumbnail.as file</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;
	import caurina.transitions.*;

	public class Thumbnail extends Sprite
	{
		private var thumb:LoadImage;
		public var myWidth:Number;
		public var myId:Number;
		public var active:Boolean;

		public function Thumbnail(img:String, id:Number)
		{
			// set this id
			myId = id;

			// load in the image
			thumb = new LoadImage( img );
			addChild ( thumb );

			// check the image load
			addEventListener ( Event.ENTER_FRAME, checkLoad );
		}

		private function checkLoad ( e:Event ):void
		{
			if ( thumb.setComplete() &#038;&#038; thumb.w() > 0)
			{
				// remove the listener
				removeEventListener ( Event.ENTER_FRAME, checkLoad );

				// get the width
				myWidth = thumb.w();
			}
		}

		public function defaultState()
		{
			active = false;
			Tweener.addTween(this, {alpha: 1, time:1, transition:"easeOut"});
		}

		public function activeState()
		{
			active = true;
			Tweener.addTween(this, {alpha: .1, time:3, transition:"easeOut"});
		}

		public function getState()
		{
			return active;
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/09/image-gallery-part-vi-active-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>APE &#8211; Basketball</title>
		<link>http://manewc.com/2008/12/04/ape-basketball/</link>
		<comments>http://manewc.com/2008/12/04/ape-basketball/#comments</comments>
		<pubDate>Thu, 04 Dec 2008 17:42:30 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=236</guid>
		<description><![CDATA[To play around a little more from the find of the draggable objects in APE I made a little demo of a basketball game.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEBasketballPost_1420798065"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEBasketball/APEBasketballPost.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEBasketball/APEBasketballPost.swf"
			name="fm_APEBasketballPost_1420798065"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
Here is the code:

package {
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.MouseEvent;

    import org.cove.ape.*;

	public class Main extends Sprite {

		private var circle:DragableCircleParticle;
		private [...]]]></description>
			<content:encoded><![CDATA[<p>To play around a little more from the find of the <a href="/2008/12/03/ape-multiple-draggable-particles/">draggable objects in APE</a> I made a little demo of a basketball game.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APEBasketballPost_281678917"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/APEBasketball/APEBasketballPost.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APEBasketball/APEBasketballPost.swf"
			name="fm_APEBasketballPost_281678917"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the code:</p>
<pre name="code" class="c-sharp">
package {
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.MouseEvent;

    import org.cove.ape.*;

	public class Main extends Sprite {

		private var circle:DragableCircleParticle;
		private var circle2:DragableCircleParticle;

		public function Main()
		{
			init();
		}

		private function init():void
		{
			stage.frameRate = 55;

			// Initialize the engine. The argument here is the time step value.
			// Higher values scale the forces in the sim, making it appear to run
			// faster or slower. Lower values result in more accurate simulations.
			APEngine.init(1/4);

			// set up the default diplay container
			APEngine.container = this;

			APEngine.addMasslessForce(new Vector(0,5));

			var defaultGroup:Group = new Group();

			defaultGroup.collideInternal = true;

			/* RECTANGLE PROPERTIES
				x:Number,
				y:Number,
				width:Number,
				height:Number,
				rotation:Number = 0,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/
            var floor:RectangleParticle = new RectangleParticle(stage.stageWidth/2, stage.stageHeight + 48, stage.stageWidth, 100, 0, true, 10);
            defaultGroup.addParticle(floor);

			var ceil:RectangleParticle = new RectangleParticle(stage.stageWidth/2, -50, stage.stageWidth, 100, 0, true, 10);
            defaultGroup.addParticle(ceil);

			var left:RectangleParticle = new RectangleParticle(-25, stage.stageHeight/2, 50, stage.stageHeight, 0, true, 10);
            defaultGroup.addParticle(left);

			var right:RectangleParticle = new RectangleParticle(stage.stageWidth+25, stage.stageHeight/2, 50, stage.stageHeight, 0, true, 10);
            defaultGroup.addParticle(right);

			/* CIRCLE PROPERTIES
				x:Number,
				y:Number,
				radius:Number,
				fixed:Boolean = false,
				mass:Number = 1,
				elasticity:Number = 0.3,
				friction:Number = 0
			*/

			/* BASKETBALL
			------------------
			*/
           	circle = new DragableCircleParticle(350, 150, 30, false, 20, .5);
			circle.setStyle(0, 0, 0, 0x993300);
			defaultGroup.addParticle(circle);

			/* HOOP &#038; NET
			------------------
			*/
			var hl:CircleParticle = new CircleParticle( stage.stageWidth - 180, 300, 5, true );
			defaultGroup.addParticle ( hl ); // hoop top left

			var hl2:CircleParticle = new CircleParticle( stage.stageWidth - 170, 350, 5, false );
			defaultGroup.addParticle ( hl2 ); // hoop top left

			var hl3:CircleParticle = new CircleParticle( stage.stageWidth - 145, 430, 5, false );
			defaultGroup.addParticle ( hl3 ); // hoop top left

			var hlConnector:SpringConstraint = new SpringConstraint(hl, hl2, 0.5, true, 8);
			hlConnector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hlConnector);  

			var hl2Connector:SpringConstraint = new SpringConstraint(hl2, hl3, 0.5, true, 8);
			hl2Connector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hl2Connector);  

			var hr:CircleParticle = new CircleParticle( stage.stageWidth - 50, 300, 5, true );
			defaultGroup.addParticle ( hr ); // hoop top right

			var hr2:CircleParticle = new CircleParticle( stage.stageWidth - 60, 350, 5, false );
			defaultGroup.addParticle ( hr2 ); // hoop top left

			var hr3:CircleParticle = new CircleParticle( stage.stageWidth - 85, 430, 5, false );
			defaultGroup.addParticle ( hr3 ); // hoop top left

			var hrConnector:SpringConstraint = new SpringConstraint(hr, hr2, 0.5, true, 8);
			hrConnector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hrConnector);

			var hr2Connector:SpringConstraint = new SpringConstraint(hr2, hr3, 0.5, true, 8);
			hr2Connector.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(hr2Connector);

			// top of hoop connector
			var thoop:SpringConstraint = new SpringConstraint(hl, hr, 4, false, 8);
			thoop.setStyle(4, 0xffffff, 4, 0xffffff);
			defaultGroup.addConstraint(thoop);

			// bottom of hoop
			var bhoop:SpringConstraint = new SpringConstraint(hl2, hr2, 0.5, false, 8);
			bhoop.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(bhoop);

			var bhoop2:SpringConstraint = new SpringConstraint(hl3, hr3, 0.5, false, 8);
			bhoop2.setStyle(0, 0x2c2c2c, 1, 0x2c2c2c);
			defaultGroup.addConstraint(bhoop2);

			// backboard
			var bb:RectangleParticle = new RectangleParticle(stage.stageWidth - 20, 220, 5, 200, 0, true, 1,.01);
			defaultGroup.addParticle ( bb ); // backboard

			APEngine.addGroup(defaultGroup);
			addEventListener(Event.ENTER_FRAME, run);
		}

		private function run(e:Event):void
		{
			APEngine.step();
			APEngine.paint();
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/12/04/ape-basketball/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
