<?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; Tweener</title>
	<atom:link href="http://manewc.com/category/tweener/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>Tweener Animation to a Point</title>
		<link>http://manewc.com/2008/07/22/tweener-animation-to-a-point/</link>
		<comments>http://manewc.com/2008/07/22/tweener-animation-to-a-point/#comments</comments>
		<pubDate>Tue, 22 Jul 2008 18:13:28 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=153</guid>
		<description><![CDATA[So I recently had an inquiry on how to use Tweener to animate an object on an angle, fortunately there is a simple method in which you just animate the x and y parameters of an object simultaneously. I created this little demo to animate a box that will tween from the top left corner [...]]]></description>
			<content:encoded><![CDATA[<p>So I recently had an inquiry on how to use Tweener to animate an object on an angle, fortunately there is a simple method in which you just animate the x and y parameters of an object simultaneously. I created this little demo to animate a box that will tween from the top left corner to where you click your mouse within the stage.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ClickAnimation_618286764"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/StageClickAnimation/ClickAnimation.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/StageClickAnimation/ClickAnimation.swf"
			name="fm_ClickAnimation_618286764"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Document Class:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.MouseEvent;
	import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
	import caurina.transitions.*;

	public class ClickAnimation extends Sprite
	{
		// objects
		private var obj1:PageOne;

		public function ClickAnimation()
		{
			// set the stage
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;

			// key events
            stage.addEventListener ( MouseEvent.MOUSE_DOWN, AnimatePoint );
		}

		public function AnimatePoint (m:MouseEvent):void
		{
			obj1 = new PageOne();
			addChild ( obj1 );

			Animate ( obj1, mouseX, mouseY );
		}

		/*
		THEATER DISPLAY CONTROL
		============================================================
		*/
		private function Animate( obj:DisplayObject,xPos:Number,yPos:Number ):void
		{
			Tweener.addTween(obj, {x:xPos, time:1.0, transition:"easeOutBack"});
			Tweener.addTween(obj, {y:yPos, time:1.0, transition:"easeOutBack"});
		}

	}
}
</pre>
<p>A class for my object:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;

	public class PageOne extends Sprite
	{
		public function PageOne()
		{
			var p = new RoundRectangle( 0, 0, 20, 20, 10, Math.random() * 0xffffff );
			addChildAt ( p, 0 );
		}
	}
}
</pre>
<p>A class to create a round rectangle&#8221;</p>
<pre name="code" class="c-sharp">
package
{
    import flash.display.DisplayObject;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;

    public class RoundRectangle extends Sprite {
        private var rrX:Number;
		private var rrY:Number;
		private var rrRadius:Number;
		private var rrWidth:Number;
		private var rrHeight:Number;
        private var bgColor:uint;
        private var borderColor:uint;
        private var borderSize:Number;
		private var child:Shape = new Shape();

        public function RoundRectangle(rrX:Number=0,rrY:Number=0,rrWidth:Number=10,rrHeight:Number=10,rrRadius:Number=0,bgColor:uint=0x000000)
		{
            child = new Shape();
            child.graphics.beginFill(bgColor);
           	child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawRoundRect(rrX, rrY, rrWidth, rrHeight, rrRadius);

            child.graphics.endFill();
            addChild(child);
        }

		public function clearRR(){
			this.graphics.clear();
		}

    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/07/22/tweener-animation-to-a-point/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing Objects with Tweener</title>
		<link>http://manewc.com/2008/07/16/changing-objects-with-tweener/</link>
		<comments>http://manewc.com/2008/07/16/changing-objects-with-tweener/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 17:59:05 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=149</guid>
		<description><![CDATA[A simple demo to show how to toggle from one object to another using tweener. Hit 1, 2, or  3 on your keyboard to demonstrate. For my project here I have 3 separate .as files that can perform anything that you code, for my demo though I just have 3 separate RoundRectangle objects.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ToggleAnimation_2034394730"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/projects/flash/ToggleAnimation/ToggleAnimation.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ToggleAnimation/ToggleAnimation.swf"
			name="fm_ToggleAnimation_2034394730"
			width="400"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>]]></description>
			<content:encoded><![CDATA[<p>A simple demo to show how to toggle from one object to another using tweener. Hit 1, 2, or  3 on your keyboard to demonstrate. For my project here I have 3 separate .as files that can perform anything that you code, for my demo though I just have 3 separate RoundRectangle objects.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ToggleAnimation_1900762240"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/ToggleAnimation/ToggleAnimation.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ToggleAnimation/ToggleAnimation.swf"
			name="fm_ToggleAnimation_1900762240"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here is the Main document class:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
	import caurina.transitions.*;

	public class ToggleAnimation extends Sprite
	{
		// theater area
		private var _theater:Sprite;

		// current page
		private var CurrentObject:DisplayObject;

		// objects
		private var obj1:PageOne;
		private var obj2:PageTwo;
		private var obj3:PageThree;

		public function ToggleAnimation()
		{
			// set the stage
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;

			// add the theater object placeholder
			_theater = new Sprite();
			addChild ( _theater );

			// key events
            stage.addEventListener ( KeyboardEvent.KEY_DOWN, PageControl );
		}

		public function PageControl (k:KeyboardEvent):void
		{
			if ( k.keyCode == 49 )
			{
				obj1 = new PageOne();
				HelloTheater ( obj1 );
			}
			else if ( k.keyCode == 50 )
			{
				obj2 = new PageTwo();
				HelloTheater ( obj2 );
			}
			else if ( k.keyCode == 51 )
			{
				obj3 = new PageThree();
				HelloTheater ( obj3 );
			}
		}

		/*
		THEATER DISPLAY CONTROL
		============================================================
		*/
		private function HelloTheater( obj:DisplayObject ):void
		{
			// flyout the first object
			ByeTheater( CurrentObject );

			// set the current object
			CurrentObject = obj;

			// slide off the screen
			obj.y = stage.stageHeight;

			// add object to the theater
			_theater.addChild( obj );

			// slide in to the screen
			Tweener.addTween(obj, {y:0, time:1.0, transition:"easeOutBack"});
		}

		private function ByeTheater( dobj:DisplayObject ):void
		{
			if ( dobj )
			{
				Tweener.addTween(dobj, {x:400, time:1.2, transition:"easeInBack", onComplete: function(){ _theater.removeChild ( dobj );dobj = null; }});
			}
		}

	}
}
</pre>
<p>The class to create a Round Rectangle</p>
<pre name="code" class="c-sharp">
package
{
    import flash.display.DisplayObject;
    import flash.display.Graphics;
    import flash.display.Shape;
    import flash.display.Sprite;

    public class RoundRectangle extends Sprite {
        private var rrX:Number;
		private var rrY:Number;
		private var rrRadius:Number;
		private var rrWidth:Number;
		private var rrHeight:Number;
        private var bgColor:uint;
        private var borderColor:uint;
        private var borderSize:Number;
		private var child:Shape = new Shape();

        public function RoundRectangle(rrX:Number=0,rrY:Number=0,rrWidth:Number=10,rrHeight:Number=10,rrRadius:Number=0,bgColor:uint=0x000000)
		{
            child = new Shape();
            child.graphics.beginFill(bgColor);
           	child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawRoundRect(rrX, rrY, rrWidth, rrHeight, rrRadius);

            child.graphics.endFill();
            addChild(child);
        }

		public function clearRR(){
			this.graphics.clear();
		}

    }
}
</pre>
<p>The classes for each page:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;

	public class PageOne extends Sprite
	{
		public function PageOne()
		{
			var p = new RoundRectangle( 0, 0, 200, 200, 10, 0x000000 );
			addChildAt ( p, 0 );
		}
	}
}
</pre>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;

	public class PageTwo extends Sprite
	{
		public function PageTwo()
		{
			var p = new RoundRectangle( 0, 0, 200, 200, 10, 0xcccccc );
			addChildAt ( p, 0 );
		}
	}
}
</pre>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;

	public class PageThree extends Sprite
	{
		public function PageThree()
		{
			var p = new RoundRectangle( 0, 0, 200, 200, 10, 0x336699 );
			addChildAt ( p, 0 );
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/07/16/changing-objects-with-tweener/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Image Gallery &#8211; Part III &#8211; Categories</title>
		<link>http://manewc.com/2008/06/24/image-gallery-part-iii-categories/</link>
		<comments>http://manewc.com/2008/06/24/image-gallery-part-iii-categories/#comments</comments>
		<pubDate>Tue, 24 Jun 2008 18:19:45 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Image Effects]]></category>
		<category><![CDATA[Image Gallery Project]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=139</guid>
		<description><![CDATA[So, a little more functionality to our Image Gallery project &#8211; I just wanted to add more functionality by allowing the user to toggle between different sets of Image Galleries. For this example you can toggle between 2 galleries by hitting &#8216;1&#8242; or &#8216;2&#8242; on your keyboard.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageGallery_319454285"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/ImageGallery3/ImageGallery.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ImageGallery3/ImageGallery.swf"
			name="fm_ImageGallery_319454285"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
I made some slight modifications [...]]]></description>
			<content:encoded><![CDATA[<p>So, a little more functionality to our Image Gallery project &#8211; I just wanted to add more functionality by allowing the user to toggle between different sets of Image Galleries. For this example you can toggle between 2 galleries by hitting &#8216;1&#8242; or &#8216;2&#8242; on your keyboard.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageGallery_719891918"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/ImageGallery3/ImageGallery.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ImageGallery3/ImageGallery.swf"
			name="fm_ImageGallery_719891918"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>I made some slight modifications to the classes. First, I created a new class that will represent our Main Document class named Main.as and took out the array of images in the ImageGallery.as file so that the Main.as file could pass in a new array to have a gallery populated. Here are the two classes:</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.display.DisplayObject;
	import flash.display.DisplayObjectContainer;
	import flash.events.KeyboardEvent;

	public class Main extends Sprite
	{
		private var GalleryImagesArr:Array;
		private var CatGallery:ImageGallery;
		private var theater:Sprite;

		public function Main()
		{
			theater = new Sprite();
			addChild ( theater );

			// set the stage
			categoryOne();

			// set the listener
			stage.addEventListener ( KeyboardEvent.KEY_DOWN, changeCategory );
		}

		private function categoryOne():void
		{
			GalleryImagesArr = new Array();
			GalleryImagesArr[0] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon0.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge0.jpg");
			GalleryImagesArr[1] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon1.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge1.jpg");
			GalleryImagesArr[2] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon2.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge2.jpg");
			GalleryImagesArr[3] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon3.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge3.jpg");
			GalleryImagesArr[4] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon4.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge4.jpg");
			GalleryImagesArr[5] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon5.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge5.jpg");
			GalleryImagesArr[6] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon6.jpg","http://manewc.com/projects/flash/i/imagegallery/avon6.jpg");
			GalleryImagesArr[7] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon7.jpg","http://manewc.com/projects/flash/i/imagegallery/avon7.jpg");
			GalleryImagesArr[8] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon8.jpg","http://manewc.com/projects/flash/i/imagegallery/avon8.jpg");
			GalleryImagesArr[9] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon9.jpg","http://manewc.com/projects/flash/i/imagegallery/avon9.jpg");

			CatGallery = new ImageGallery ( GalleryImagesArr );
			theater.addChild ( CatGallery );
		}

		private function categoryTwo():void
		{

			GalleryImagesArr = new Array();
			GalleryImagesArr[0] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0123.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0123.jpg");
			GalleryImagesArr[1] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0220.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0220.jpg");
			GalleryImagesArr[2] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0222.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0222.jpg");
			GalleryImagesArr[3] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0239.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0239.jpg");
			GalleryImagesArr[4] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0263.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0263.jpg");
			GalleryImagesArr[5] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0268.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0268.jpg");
			GalleryImagesArr[6] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0289.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0289.jpg");
			GalleryImagesArr[7] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0983.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0983.jpg");
			GalleryImagesArr[8] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0989.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0989.jpg");
			GalleryImagesArr[9] = new Array("http://manewc.com/projects/flash/i/imagegallery/hyannis/thmb0998.jpg","http://manewc.com/projects/flash/i/imagegallery/hyannis/0998.jpg");

			CatGallery = new ImageGallery ( GalleryImagesArr );
			theater.addChild ( CatGallery );
		}

		private function changeCategory ( k:KeyboardEvent ):void
		{
			if ( k.keyCode == 49 )
			{
				cleanChildren();
				categoryOne();
			}
			else if ( k.keyCode == 50 )
			{
				cleanChildren();
				categoryTwo();
			}
		}

		private var theaterArr:Array;
		private var childrenArr:Array;

		private function cleanChildren()
		{
			// get children
			theaterArr = traceChildren ( theater );

			// find children, if exist then delete
			for ( var t:uint = 0; t < theaterArr.length; t++ )
			{
				if ( theaterArr[t] == "[object ImageGallery]" )
				{
					theater.removeChild( theaterArr[t] );
					theaterArr[t] = null;
				}
			}
		}

		private function traceChildren(d:Sprite)
        {
			childrenArr = new Array();

            for ( var k:uint; k < d.numChildren; k++ )
            {
                var o:DisplayObject = d.getChildAt(k);  

                if ( o is DisplayObjectContainer )
                {
                    childrenArr.push ( o );
                }
                else
                {
					// childrenArr.push ( "" );
                }
            }

			return childrenArr;

        }
	}
}
</pre>
<p>and the ImageGallery.as</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 );
		}

		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 );
			}
		}

		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
		{
			Tweener.addTween(m.currentTarget, {alpha: 1, time:.8, transition:"easeOutBack"});
			Tweener.addTween(m.currentTarget, {y: -20, time:2, transition:"easeOut"});
		}

		private function ThumbDown (m:MouseEvent):void
		{
			// re initialize the index value
			CurrentIndex = m.currentTarget.myId;

			if ( MainImage ) removeChild ( MainImage );

			MainImage = new LargeImage ( ThumbArray[CurrentIndex][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 ThumbOut (m:MouseEvent):void
		{
			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>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/06/24/image-gallery-part-iii-categories/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Image Gallery &#8211; Part II &#8211; The Large Image</title>
		<link>http://manewc.com/2008/06/23/image-gallery-part-ii-the-large-image/</link>
		<comments>http://manewc.com/2008/06/23/image-gallery-part-ii-the-large-image/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 17:49:56 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Image Effects]]></category>
		<category><![CDATA[Image Gallery Project]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=137</guid>
		<description><![CDATA[So, at this point we have the scrolling menu with our thumbnail images and now I have added an event listener so when the user clicks the thumbnail it will display the related larger image. Please note that at the moment I don&#8217;t have the large images for all the thumbnails, that is why a [...]]]></description>
			<content:encoded><![CDATA[<p>So, at this point we have the scrolling menu with our thumbnail images and now I have added an event listener so when the user clicks the thumbnail it will display the related larger image. Please note that at the moment I don&#8217;t have the large images for all the thumbnails, that is why a thumbnail image is being used to represent a large image.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_ImageGallery_1855648562"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/ImageGallery2/ImageGallery.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/ImageGallery2/ImageGallery.swf"
			name="fm_ImageGallery_1855648562"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>In addition to the Tweener class library, here are my classes:</p>
<p>The Main Document Class:</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()
		{
			init();

			ButtonIndex = VisibleThumbnails;
		}

		private function init():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;

			// the array of the thumbnail images
			ThumbArray = new Array();
			ThumbArray[0] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon0.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge0.jpg");
			ThumbArray[1] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon1.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge1.jpg");
			ThumbArray[2] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon2.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge2.jpg");
			ThumbArray[3] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon3.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge3.jpg");
			ThumbArray[4] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon4.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge4.jpg");
			ThumbArray[5] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon5.jpg","http://manewc.com/projects/flash/i/imagegallery/avonlarge5.jpg");
			ThumbArray[6] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon6.jpg","http://manewc.com/projects/flash/i/imagegallery/avon6.jpg");
			ThumbArray[7] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon7.jpg","http://manewc.com/projects/flash/i/imagegallery/avon7.jpg");
			ThumbArray[8] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon8.jpg","http://manewc.com/projects/flash/i/imagegallery/avon8.jpg");
			ThumbArray[9] = new Array("http://manewc.com/projects/flash/i/imagegallery/avon9.jpg","http://manewc.com/projects/flash/i/imagegallery/avon9.jpg");

			// 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 );
		}

		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 );
			}
		}

		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
		{
			Tweener.addTween(m.currentTarget, {alpha: 1, time:.8, transition:"easeOutBack"});
			Tweener.addTween(m.currentTarget, {y: -20, time:2, transition:"easeOut"});
		}

		private function ThumbDown (m:MouseEvent):void
		{
			// re initialize the index value
			CurrentIndex = m.currentTarget.myId;

			if ( MainImage ) removeChild ( MainImage );

			MainImage = new LargeImage ( ThumbArray[CurrentIndex][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 ThumbOut (m:MouseEvent):void
		{
			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>The new LargeImage.as class file:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
    import flash.net.URLRequest;
    import flash.filters.BlurFilter;
    import flash.filters.BitmapFilterQuality;
	import flash.events.Event;
	import flash.events.ProgressEvent;
    import caurina.transitions.Tweener

	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFormat;

	public class LargeImage extends Sprite {
		private var loStatus:TextField;
		private var loImageLoader:Loader = new Loader();
		private var lnDistance:Number = 10;
		//public var loTimer:Timer = new Timer(10); //default interval

		private var filter:BlurFilter;
		private var filtersArray:Array;

		public function LargeImage(imgURL:String){
			this.Blur(imgURL);
		}

		private function Blur(imgURL:String):void {
			CreateTextField(); // preloader text box
			try {
				this.loImageLoader.load(new URLRequest(imgURL));
			} catch (loError:Error) {
				this.loStatus.text = "Unable to load requested document.";
			}

			this.loImageLoader.contentLoaderInfo.addEventListener(Event.OPEN, this.openEvents);
			this.loImageLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, this.progressEvents);
			this.loImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, this.loadCompleteEvents);
		}

		public function openEvents(loEvent:Event):void
		{
			this.loStatus.text = "Opening File";
		}

		public function progressEvents(loEvent:ProgressEvent):void
		{
			this.loStatus.text = "loading: " + loEvent.bytesLoaded + " bytes out of " + loEvent.bytesTotal;
		}

		public function loadCompleteEvents(loEvent:Event):void
		{
			this.loStatus.text = "";
			this.loImageLoader.y = 0;
			this.loImageLoader.x = (stage.stageWidth / 2) - (this.loImageLoader.width / 2);
			addChild(this.loImageLoader); //display image

			var filter:BlurFilter=new BlurFilter(10,10,BitmapFilterQuality.MEDIUM);
            var filters_array:Array=new Array();
            filters_array.push(filter); 

			loImageLoader.filters=filters_array;

			Tweener.addTween(this.loImageLoader,{_blur_blurX:0,_blur_blurY:0, time:.5});
		}

		private function CreateTextField():void
		{
			this.loStatus = new TextField();
			this.loStatus.autoSize = TextFieldAutoSize.LEFT;
			this.loStatus.background = false;
			this.loStatus.border = false;
			var format:TextFormat = new TextFormat();
			format.font = "Verdana";
			format.color = 0xffffff;
			format.size = 10;
			format.underline = false;
			this.loStatus.defaultTextFormat = format;
			addChild(this.loStatus);
		}
	}
}
</pre>
<p>The class to load images:</p>
<pre name="code" class="c-sharp">
package {
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.events.IEventDispatcher;
    import flash.net.URLRequest;

    public class LoadImage extends Sprite {
        private var url:String;
		private var imageHolder:Sprite;
		public var LoadImageArray:Array = new Array();
		public var bits:Number;
		public var bitsLoaded:Number;
		public var totalBits:Number;
		private var loader:Loader;

		private var completeStatus:Boolean = false;

        public function LoadImage(url:String) {
			var loader:Loader = new Loader();
            configureListeners(loader.contentLoaderInfo);

            var request:URLRequest = new URLRequest( url );
            loader.load(request);

			imageHolder = new Sprite();
			addChild ( imageHolder );
			imageHolder.addChild(loader);
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
			dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			addEventListener(Event.COMPLETE, completeHandler);

        }

        private function completeHandler(event:Event):void {
			removeEventListener(Event.COMPLETE, completeHandler);
			setComplete();
		}

		public function setComplete()
		{
			completeStatus = true;
			return ( completeStatus );
		}

		public function getBits()
		{
			return ( bits );
		}

		public function getBitsLoaded()
		{
			return ( bitsLoaded );
		}

		public function w()
		{
			return this.width;
		}

        private function progressHandler(event:ProgressEvent):void {
			bitsLoaded = event.bytesLoaded;
			bits = event.bytesTotal;
        }
    }
}
</pre>
<p>and my Thumbnail.as class file</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.events.Event;

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

		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();
			}
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/06/23/image-gallery-part-ii-the-large-image/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Time Machine Animation with Tweener</title>
		<link>http://manewc.com/2008/06/12/time-machine-animation-with-tweener/</link>
		<comments>http://manewc.com/2008/06/12/time-machine-animation-with-tweener/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 17:24:53 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Preloading]]></category>
		<category><![CDATA[Timer Methods]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=128</guid>
		<description><![CDATA[So I am trying to think of a way to create some type of &#8220;Time Machine&#8221; animation. Fortunately with the help of Tweener, this is what I came up with &#8211; Please note that this is a work in progress. You will need to click the movie first to activate the keyboard events.
So the number [...]]]></description>
			<content:encoded><![CDATA[<p>So I am trying to think of a way to create some type of &#8220;Time Machine&#8221; animation. Fortunately with the help of Tweener, this is what I came up with &#8211; <strong>Please note that this is a work in progress</strong>. You will need to click the movie first to activate the keyboard events.</p>
<p>So the number represents the key, and the fruit represents the images that will appear.</p>
<p>0 = blueberry<br />
1 = pineapple orange banana<br />
2 = coconut<br />
3 = strawberry pomegranate<br />
4 = blackraspberry<br />
5 = lime lemon<br />
6 = peach mango</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TimeMachine_216964501"
			class="flashmovie"
			width="700"
			height="500">
	<param name="movie" value="/projects/flash/TimeMachine/TimeMachine.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/TimeMachine/TimeMachine.swf"
			name="fm_TimeMachine_216964501"
			width="700"
			height="500">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Here are the classes, Document Class Main.as is first &#8211; please note that this is a rough draft of this animation, the preloading of images do not work that well and I will eventually need to add some setter and getter methods to the TimeMachine class &#8211; the final version to be posted some time in the future.. Also note that this demo actually loads the images in twice, my thought was that during the initial load it would essentially cache the images, but this is not working properly &#8211; if you refresh this page you will see what I mean:</p>
<pre name="code" class="c-sharp">
package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.geom.Point;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	import flash.text.TextFormat;
	import flash.text.TextField;
	import fl.controls.TextArea;
	import fl.controls.ScrollPolicy;
	import flash.display.DisplayObject;
    import flash.display.DisplayObjectContainer;
	import flash.events.TimerEvent;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;

	import caurina.transitions.*;

	public class Main extends Sprite
	{
		// array of all images to be prelaoded before the movie begins:
		private var imgArray:Array;

		// the class to handle all the images
		private var imgPreload:MultipleImagePreload;

		//text area component
		private var output:TextArea;

		// Time Machine
		private var TimeMachine:TimeMachineAnimation;

		public function Main()
		{
			// set the stage
			stage.align = StageAlign.TOP_LEFT;
			stage.scaleMode = StageScaleMode.NO_SCALE;

			// for debugging
			showOutput();

			// preload all the images
			preloadImages();

		}

		/*
		PRELOAD ALL THE IMAGES

		*/
		private function preloadImages():void
		{

			imgArray = new Array();
			imgArray[0] = "http://manewc.com/projects/flash/i/infused-blueberry.jpg";
			imgArray[1] = "http://manewc.com/projects/flash/i/infused-pineappleorangebanana.jpg";
			imgArray[2] = "http://manewc.com/projects/flash/i/infused-coconut.jpg";
			imgArray[3] = "http://manewc.com/projects/flash/i/infused-strawberrypomegranate.jpg";
			imgArray[4] = "http://manewc.com/projects/flash/i/infused-blackraspberry.jpg";
			imgArray[5] = "http://manewc.com/projects/flash/i/infused-limelemon.jpg";
			imgArray[6] = "http://manewc.com/projects/flash/i/infused-peachmango.jpg";

			imgPreload = new MultipleImagePreload(imgArray);
			addChild ( imgPreload );

			// trace ( imgPreload.loadArray );

			stage.addEventListener ( Event.ENTER_FRAME, checkPreload );
		}

		private function checkPreload(e:Event):void
		{
			if ( imgPreload.chkLoaded )
			{
				Message ( "\n====================\nALL IMAGES LOADED\n====================\n" );

				stage.removeEventListener ( Event.ENTER_FRAME, checkPreload );

				Message ( "\n1. Start Animation\n" );
				BeginTimeMachine();
			}
		}

		/*
		BeginTimeMachine

		*/
		private function BeginTimeMachine():void
		{
			TimeMachine = new TimeMachineAnimation ( imgArray );
			addChild ( TimeMachine );

			TimeMachine.x = stage.stageWidth / 2;
			TimeMachine.y = stage.stageHeight / 2;

			// add the event
			stage.addEventListener (KeyboardEvent.KEY_DOWN, animTimeMachine);
		}

		private function animTimeMachine ( k:KeyboardEvent ):void
		{
			if ( TimeMachine.animationComplete )
			{
				switch ( k.keyCode )
				{
					case 48:
						TimeMachine.setIndex ( 0 );
						break;

					case 49:
						TimeMachine.setIndex ( 1 );
						break;

					case 50:
						TimeMachine.setIndex ( 2 );
						break;

					case 51:
						TimeMachine.setIndex ( 3 );
						break;

					case 52:
						TimeMachine.setIndex ( 4 );
						break;

					case 53:
						TimeMachine.setIndex ( 5 );
						break;

					case 54:
						TimeMachine.setIndex ( 6 );
						break;

					default:
						break;
				}
			}
		}

		/*
		FOR DEBUGGING

		*/
		private function showOutput():void
        {
			output = new TextArea();
			output.verticalScrollPolicy = ScrollPolicy.ON;
			output.condenseWhite = true;
			output.setSize(stage.stageWidth, 300);
			output.move(0, 680);
			addChild(output);
        }

		public function Message(msg:String):void
		{
			output.appendText ( msg );
		}

		private var childrenArr:Array;

		public function traceChildren(d:Sprite)
        {
			childrenArr = new Array();

            for ( var k:uint; k < d.numChildren; k++ )
            {
                var o:DisplayObject = d.getChildAt(k);  

                if ( o is DisplayObjectContainer )
                {
                    childrenArr.push ( o );
                }
                else
                {
					// childrenArr.push ( "" );
                    // trace ( o );
                }
            }

			return childrenArr;

        }  

	}
}
</pre>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.utils.Timer;
    import flash.events.TimerEvent;
	import flash.events.MouseEvent;
	import flash.events.KeyboardEvent;
	// tweener
	import caurina.transitions.*;

	public class TimeMachineAnimation extends Sprite
	{
		private var tArr:Array;
		private var imgArr:Array;
		private var ct:Number =			0;
		public var currentIndex = 		0;

		public function TimeMachineAnimation (a:Array)
		{
			// Re Assign
			tArr = a;

			// Create an Object for each item of the Array
			imgArr = new Array();
			tArr.forEach ( BuildObject );

			// Send off each item of the array to offscreen bottom
			imgArr.forEach( Position );  

			// begin the timer
			setTimer();
		}

		private function BuildObject(element:*, index:int, arr:Array):void
		{
			imgArr[index] = new LoadImage ( tArr[index] );
		}

		private function Position(element:*, index:int, arr:Array):void
		{
			imgArr[index].y = 1400;

			imgArr[index].scaleX = ( 1 / (imgArr.length-1) ) * index;
			imgArr[index].scaleY = ( 1 / (imgArr.length-1) ) * index;

			addChild ( imgArr[index] );
		}

		private function setTimer():void
		{
			ct = 0;

			var myTimer:Timer = new Timer(100, imgArr.length);
            myTimer.addEventListener("timer", timerHandler);
            myTimer.start();
		}

		private function timerHandler(e:TimerEvent):void
		{

			Tweener.addTween(imgArr[ct], {y: 0, time:.7, transition:"easeOutBack"});

			ct++;

			currentIndex = ct;

			if ( ct == imgArr.length )
			{
				setIndex ( imgArr.length );
			}
		}

		private var motionDirection:Number;
		private var motionCount:Number;
		private var mct:Number = 0;
		private var stopZ:Number;

		private var animCounter:Number = 0;
		public var animationComplete:Boolean;

		public function setIndex(i:Number):void
		{
			// update the animation counter
			animCounter = 0;

			// toggle for the animation status
			animationComplete = true;

			// need to know the current index
			motionDirection = currentIndex - i;

			stopZ = i;

			if ( motionDirection > 0 )
			{
				motionCount =  motionDirection;

				mct = imgArr.length;

				var closeTimer:Timer = new Timer(600, motionCount);
           		closeTimer.addEventListener("timer", moveTowards);
            	closeTimer.start();
			}
			else if ( motionDirection < 0 )
			{
				motionCount =  Math.abs(motionDirection);

				mct = imgArr.length;

				var awayTimer:Timer = new Timer(600, motionCount);
           		awayTimer.addEventListener("timer", moveAway);
            	awayTimer.start();
			}
		}

		private function moveTowards ( t:TimerEvent ):void
		{
			Tweener.addTween(imgArr[currentIndex], {scaleX: 1.5, time:.5, transition:"easeOutBack"});
			Tweener.addTween(imgArr[currentIndex], {scaleY: 1.5, time:.5, transition:"easeOutBack"});
			Tweener.addTween(imgArr[currentIndex], {alpha: 0, time:1.6, transition:"easeOutBack"});

			for ( var u:Number = currentIndex; u > 0; u-- )
			{
				Tweener.addTween(imgArr[currentIndex-u], {scaleX: 1, time:3, transition:"easeOut"});
				Tweener.addTween(imgArr[currentIndex-u], {scaleY: 1, time:3, transition:"easeOut"});
			}

			currentIndex--;

			animCounter++;

			if ( animCounter == motionCount ? animationComplete = true : animationComplete = false );

		}

		private function moveAway ( t:TimerEvent ):void
		{
			currentIndex++;

			imgArr[currentIndex].scaleX = 1.5;
			imgArr[currentIndex].scaleY = 1.5;
			imgArr[currentIndex].alpha = 0;

			Tweener.addTween(imgArr[currentIndex], {scaleX: 1, time:.8, transition:"easeOut"});
			Tweener.addTween(imgArr[currentIndex], {scaleY: 1, time:.8, transition:"easeOut"});
			Tweener.addTween(imgArr[currentIndex], {alpha: 1, time:1.5, transition:"easeOut"});

			animCounter++;

			if ( animCounter == motionCount ? animationComplete = true : animationComplete = false );

		}

	}

}
</pre>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.setInterval;
	import flash.utils.clearInterval;

	public class MultipleImagePreload extends Sprite
	{
		public var images:Array;
		public var chkLoaded:Boolean = false;

		private var imgArray:Array;

		// array of images.. onload event
		private var imgLoadArray:Array;

		// array of LoadImage class
		private var loadArray:Array;

		// variables for our timer events
		private var initLoadTimer:uint;
		private var preLoadTimer:uint;

		// variables for the preload process
		private var getTotalBits:Number; // the tally for the total bits
		private var imageTotalSize:Number;
		private var imagePreLoadSize:Number; // the tally for preloading

		private var preloader:Preloader;

		public function MultipleImagePreload(images:Array)
		{
			imgArray = images;

			// Load in the images.
			loadArray = new Array();

			for ( var i:uint; i < images.length; i++ )
			{
				// load the image
				loadArray[i] = new LoadImage( imgArray[i] );

				// display the image to stage
				addChild ( loadArray[i] );

				// send them off the stage
				loadArray[i].x = -9999;
			}

			// add the preloader
			preloader = new Preloader();
			addChild ( preloader );

			initLoadTimer = setInterval(onLoadImage, 500);
		}

		private function onLoadImage():void
		{
			var imgLoadArray = new Array();

			for ( var i:uint=0; i < imgArray.length; i++ )
			{
				getTotalBits = loadArray[i].getBits();

				if ( getTotalBits > 0 &#038;&#038; loadArray[i].setComplete())
				{
					// check again.
					imgLoadArray[i] = loadArray[i];
				}
			}

			if ( imgLoadArray.length == imgArray.length )
			{
				clearInterval ( initLoadTimer );

				imageTotalSize = 0;

				// add up the size of all images
				for ( var u:uint=0; u < imgArray.length; u++ )
				{
					if ( loadArray[u].getBits() ) /* Safari is requiring this */
					{
						imageTotalSize += loadArray[u].getBits();

					}
				}

				Main(root).Message( "Total Size (bits): " + imageTotalSize + "\n" );

				// we now have recorded all file sizes.. now start the preloading
				preLoadTimer = setInterval(preLoadImage, 50);
			}
		}

		private var loadStat:Number;

		private function preLoadImage():void
		{
			imagePreLoadSize = 0;

			// add up the size of all images
			for ( var p:uint=0; p < imgArray.length; p++ )
			{
				imagePreLoadSize += loadArray[p].getBitsLoaded();
			}

			if ( ( imagePreLoadSize / imageTotalSize ) )
			{
				loadStat = Math.floor(100 * (imagePreLoadSize / imageTotalSize));

				if ( loadStat >= 100 )
				{
					// clear the timer
					clearInterval ( preLoadTimer );

					// set the boolean variable to true to notify all images are loaded
					chkLoaded = true;

					Main(root).Message ("100% Loaded\n");

					removeChild ( preloader );
					preloader = null;
				}
				else
				{
					Main(root).Message (Math.floor(100 * (imagePreLoadSize / imageTotalSize)) + "% Loaded\n");

					// update the preloader
					preloader.loadStatus ( Math.floor(100 * (imagePreLoadSize / imageTotalSize)) );
				}
			}
		}
	}
}
</pre>
<pre name="code" class="c-sharp">
package {
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.Event;
	import flash.events.ProgressEvent;
	import flash.events.IEventDispatcher;
    import flash.net.URLRequest;

    public class LoadImage extends Sprite {
        private var url:String;
		private var imageHolder:Sprite;
		private var imageHolderHolder:Sprite;
		public var LoadImageArray:Array = new Array();
		public var bits:Number;
		public var bitsLoaded:Number;
		public var totalBits:Number;
		private var loader:Loader;

		public var _myWidth:Number = 10;
		public var mywidth:Number;

		private var completeStatus:Boolean = false;

        public function LoadImage(url:String) {
			var loader:Loader = new Loader();
            configureListeners(loader.contentLoaderInfo);

            var request:URLRequest = new URLRequest( url );
            loader.load(request);

			imageHolder = new Sprite();
			addChild ( loader );

			loader.y = -222;
			loader.x = -350;

			mywidth = 1;
        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
			dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			addEventListener(Event.COMPLETE, completeHandler);

        }

        private function completeHandler(event:Event):void {
			removeEventListener(Event.COMPLETE, completeHandler);

			setComplete();
		}

		public function setComplete()
		{
			completeStatus = true;

			return ( completeStatus );
		}

		public function getBits()
		{
			return ( bits );
		}

		public function getBitsLoaded()
		{
			return ( bitsLoaded );
		}

		public function getWidth()
		{
			return ( imageHolder.width );
		}

		public function w()
		{
			return imageHolder.width;
		}

        private function progressHandler(event:ProgressEvent):void {
			bitsLoaded = event.bytesLoaded;
			bits = event.bytesTotal;
        }
    }
}
</pre>
<pre name="code" class="c-sharp">
package
{
    import flash.display.Sprite;
    import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.events.Event;

    public class Preloader extends Sprite
    {
		public var tfloaded:TextField;

		public var loaded:Number;

        public function Preloader()
		{
			addEventListener ( Event.ADDED_TO_STAGE , init );
        }

		private function init(e:Event)
		{
			// Small Black Text Formatting
			var tf:TextFormat = new TextFormat();
			tf.font = "Paralucent-Light";
			tf.color = 0x4d86c6;
            tf.size = 30;
            tf.underline = false;
			tf.align = "center";

        	tfloaded = new TextField();
			tfloaded.defaultTextFormat = tf;
        	addChild(tfloaded);
        	tfloaded.width = 100;
            tfloaded.height = 100;
			tfloaded.x = 100;
        	tfloaded.y = 100;
            tfloaded.multiline = true;
            tfloaded.wordWrap = true;
			tfloaded.background = false;
			tfloaded.text = "";

			tfloaded.x = (stage.stageWidth / 2) - (tfloaded.width / 2);
		}

		public function loadStatus ( loaded:Number ):void
		{
			tfloaded.text = loaded + "%";
		}
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/06/12/time-machine-animation-with-tweener/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Papervision and Tweener &#8211; Random Motion of a Cube</title>
		<link>http://manewc.com/2008/06/06/papervision-and-tweener-random-motion-of-a-cube/</link>
		<comments>http://manewc.com/2008/06/06/papervision-and-tweener-random-motion-of-a-cube/#comments</comments>
		<pubDate>Fri, 06 Jun 2008 18:20:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Papervision]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/?p=124</guid>
		<description><![CDATA[So I have needed to learn more about the inner workings of Papervision and control of motion, so I decided to integrate Tweener. Here is just a little demo, just click the movie to give the cube motion, then when the animation is complete the listener for the Mouse Event will be active again.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_PapervisionCubeRandom_538731082"
			class="flashmovie"
			width="400"
			height="300">
	<param name="movie" value="/projects/flash/PapervisionCubeRandom/PapervisionCubeRandom.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/PapervisionCubeRandom/PapervisionCubeRandom.swf"
			name="fm_PapervisionCubeRandom_538731082"
			width="400"
			height="300">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>]]></description>
			<content:encoded><![CDATA[<p>So I have needed to learn more about the inner workings of Papervision and control of motion, so I decided to integrate Tweener. Here is just a little demo, just click the movie to give the cube motion, then when the animation is complete the listener for the Mouse Event will be active again.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_PapervisionCubeRandom_210208371"
			class="flashmovie"
			width="700"
			height="700">
	<param name="movie" value="/projects/flash/PapervisionCubeRandom/PapervisionCubeRandom.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/PapervisionCubeRandom/PapervisionCubeRandom.swf"
			name="fm_PapervisionCubeRandom_210208371"
			width="700"
			height="700">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import org.papervision3d.cameras.Camera3D;
	import org.papervision3d.materials.BitmapMaterial;
	import org.papervision3d.materials.BitmapFileMaterial;
	import org.papervision3d.materials.MaterialsList;
	import org.papervision3d.objects.DisplayObject3D;
	import org.papervision3d.scenes.Scene3D;
	import org.papervision3d.objects.Collada;
	import org.papervision3d.core.proto.DisplayObjectContainer3D;
	import org.papervision3d.objects.Cube;
	import org.papervision3d.materials.ColorMaterial;
	import caurina.transitions.*;

	public class PapervisionCubeRandom extends Sprite
	{
		// image 1 variable represents an image in the library with the class name of CubeTexture
		private var image1:BitmapData = new CubeTexture(0,0);
		private var container:Sprite;
		private var scene:Scene3D;
		private var camera:Camera3D;
		private var rootNode:DisplayObject3D;
		private var ml:MaterialsList = new MaterialsList();
		private var customcube:Cube;

		public function PapervisionCubeRandom()
		{
			init3D();

			stage.addEventListener(MouseEvent.MOUSE_DOWN, onClickHandler);
		}

		private function init3D():void {
			container = new Sprite();
			addChild( container );
			container.x = stage.stageWidth * .5;
			container.y = stage.stageHeight * .5;
			scene = new Scene3D( container );
			camera = new Camera3D();
			camera.zoom = 10;

			rootNode = scene.addChild( new DisplayObject3D("rootNode") );

			var ml:MaterialsList = new MaterialsList();
			ml.addMaterial(new BitmapFileMaterial("http://manewc.com/projects/flash/PapervisionCubeSides/ski.jpg"), 'face1');
			ml.addMaterial(new BitmapMaterial( image1 ), 'face2');
			ml.addMaterial(new BitmapMaterial( image1 ), 'face3');
			ml.addMaterial(new BitmapMaterial( image1 ), 'face4');
			ml.addMaterial(new BitmapMaterial( image1 ), 'face5');
			ml.addMaterial(new BitmapFileMaterial("http://manewc.com/projects/flash/i/gahlord.jpg"), 'face6');

			customcube = new Cube( ml, 500, 400, 100, 1, 1, 1 );
			rootNode.addChild( customcube, "myCube01" );

			scene.renderCamera(this.camera);
		}

		private function onClickHandler(m:MouseEvent):void {
			stage.removeEventListener(MouseEvent.MOUSE_DOWN, onClickHandler);

			Tweener.addTween(camera,{x:Math.random() * 2000,time:1,transition:"easeoutquint"});
			Tweener.addTween(camera,{y:Math.random() * 2000,time:1,transition:"easeoutquint"});

			var screen:DisplayObject3D = this.scene.getChildByName("rootNode");

			Tweener.addTween(screen,{rotationX:Math.random() * 360,time:1,transition:"easeoutquint"});
			Tweener.addTween(screen,{rotationY:Math.random() * 360,time:1,transition:"easeoutquint",onComplete:killListener});

			addEventListener ( Event.ENTER_FRAME, Timeline);
		}

		private function Timeline(e:Event):void
		{
			scene.renderCamera(this.camera);
		}

		private function killListener():void
		{
			removeEventListener ( Event.ENTER_FRAME, Timeline);
			stage.addEventListener(MouseEvent.MOUSE_DOWN, onClickHandler);
		}
	}
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/06/06/papervision-and-tweener-random-motion-of-a-cube/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tweener Blur Animation</title>
		<link>http://manewc.com/2008/05/06/tweener-blur-animation/</link>
		<comments>http://manewc.com/2008/05/06/tweener-blur-animation/#comments</comments>
		<pubDate>Tue, 06 May 2008 17:40:20 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/2008/05/06/tweener-blur-animation/</guid>
		<description><![CDATA[I wrote up a couple classes to utilize a blur animation effect with the use of Tweener Actionscript Library

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

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

    public class Main extends Sprite {

		private var ba:BlurAnimation;

		public function Main()
		{
			addEventListener ( Event.ADDED_TO_STAGE , init );
     [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote up a couple classes to utilize a blur animation effect with the use of <a href="http://code.google.com/p/tweener/">Tweener Actionscript Library</a></p>

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

    public class Main extends Sprite {

		private var ba:BlurAnimation;

		public function Main()
		{
			addEventListener ( Event.ADDED_TO_STAGE , init );
        }

		private function init(e:Event):void
		{
			ba = new BlurAnimation( "http://manewc.com/projects/flash/i/gahlord.jpg", 400, 400, 5 );
			addChild(ba);

			ba.x = stage.stageWidth / 2 - 245;
			ba.y = stage.stageHeight / 2 - 245;
		}
    }
}
</pre>
<p>Here is the blur animation effect using the Tweener Class</p>
<pre name="code" class="c-sharp">
package
{
	import flash.display.Sprite;
	import flash.net.URLRequest;
	import flash.filters.BlurFilter;
	import flash.filters.BitmapFilterQuality;
	import caurina.transitions.Tweener;

	public class BlurAnimation extends Sprite
	{
		private var back_mc:LoadImage;

		public function BlurAnimation(imgurl:String, xblur:Number=10, yblur:Number=10, timer:Number=1)
		{
			var filter:BlurFilter=new BlurFilter(xblur,yblur,BitmapFilterQuality.MEDIUM);
			var filters_array:Array=new Array();
			filters_array.push(filter);

			back_mc = new LoadImage(imgurl);
			addChild ( back_mc );

			back_mc.filters=filters_array;

			Tweener.addTween(back_mc,{_blur_blurX:0,_blur_blurY:0, time:timer});
		}
	}
}
</pre>
<p>A class I use to load in my images:</p>
<pre name="code" class="c-sharp">
package {
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.events.*;
    import flash.net.URLRequest;

    public class LoadImage extends Sprite {
        private var url:String;
		private var imageHolder:Sprite;
		public var LoadImageArray:Array = new Array();
		public var bits:Number;
		public var bitsLoaded:Number;
		public var totalBits:Number;
		// public var imgCompleted:Boolean;

        public function LoadImage(url:String) {

			var loader:Loader = new Loader();
            configureListeners(loader.contentLoaderInfo);

			var request:URLRequest = new URLRequest( url );
            loader.load(request);

			imageHolder = new Sprite();
			addChild ( imageHolder );
            imageHolder.addChild(loader);

        }

        private function configureListeners(dispatcher:IEventDispatcher):void {
			dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler);
			dispatcher.addEventListener(Event.COMPLETE, completeHandler);
        }

        private function completeHandler(event:Event):void {
			trace ( "image loaded complete");
		}

        private function progressHandler(event:ProgressEvent):void {
            trace ("progressHandler: bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
        }
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/05/06/tweener-blur-animation/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>[AS 3] APE and Tweener Actionscript Library Demo</title>
		<link>http://manewc.com/2008/04/04/as-3-ape-and-tweener-actionscript-library-demo/</link>
		<comments>http://manewc.com/2008/04/04/as-3-ape-and-tweener-actionscript-library-demo/#comments</comments>
		<pubDate>Fri, 04 Apr 2008 18:16:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[APE - Actionscript Physics Engine]]></category>
		<category><![CDATA[Actionscript 3]]></category>
		<category><![CDATA[Tweener]]></category>

		<guid isPermaLink="false">http://manewc.com/2008/04/04/as-3-ape-and-tweener-actionscript-library-demo/</guid>
		<description><![CDATA[A simple demonstration of combining the Actionscript Physics Engine and Tweener Actionscript Library. I have noticed that if you apply a Massless Force (ie, gravity) from the Physics Engine, then the Tweener tween will play first, then the gravity will be applied. This only effects the object that Tweener is tweening.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APETweenerMotion_1863220665"
			class="flashmovie"
			width="600"
			height="350">
	<param name="movie" value="/projects/flash/APETweenerMotion/APETweenerMotion.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APETweenerMotion/APETweenerMotion.swf"
			name="fm_APETweenerMotion_1863220665"
			width="600"
			height="350">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
The [...]]]></description>
			<content:encoded><![CDATA[<p>A simple demonstration of combining the Actionscript Physics Engine and Tweener Actionscript Library. I have noticed that if you apply a Massless Force (ie, gravity) from the Physics Engine, then the Tweener tween will play first, then the gravity will be applied. This only effects the object that Tweener is tweening.</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_APETweenerMotion_267475317"
			class="flashmovie"
			width="600"
			height="350">
	<param name="movie" value="/projects/flash/APETweenerMotion/APETweenerMotion.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/projects/flash/APETweenerMotion/APETweenerMotion.swf"
			name="fm_APETweenerMotion_267475317"
			width="600"
			height="350">
	<!--<![endif]-->
		
	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>The document class file:</p>
<pre name="code" class="c-sharp">
package {
	import caurina.transitions.Tweener;
    import flash.display.Sprite;
    import flash.events.Event;
    import org.cove.ape.*;

	public class Main extends Sprite {

		public function Main(){
			stage.frameRate = 55;
			addEventListener(Event.ENTER_FRAME, run);
			// 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;

			var defaultGroup:Group = new Group();
			defaultGroup.collideInternal = true;

            var rect:RectangleParticle = new RectangleParticle(50, 50, 20, 20, 10, false);
            defaultGroup.addParticle(rect);

            var circle:CircleParticle = new CircleParticle(350, 150, 25);
			defaultGroup.addParticle(circle);

			APEngine.addGroup(defaultGroup);

			tween(rect);
		}

        private function tween(rect:RectangleParticle):void {
	        Tweener.addTween(rect, {px:350, py:150, time:1.2,transition:"easeInOutQuint"})
		}

		private function run(e:Event):void {
			APEngine.step();
			APEngine.paint();
		}
	}
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://manewc.com/2008/04/04/as-3-ape-and-tweener-actionscript-library-demo/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
