<?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>Brady White &#187; motion tweens</title>
	<atom:link href="http://www.bradywhite.net/tag/motion-tweens/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.bradywhite.net</link>
	<description>Adobe Flex/Flash and Life</description>
	<lastBuildDate>Tue, 18 May 2010 15:49:13 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Scripted Motion Tweens Tutorial</title>
		<link>http://www.bradywhite.net/2004/11/14/penner-tweens-tutorial/</link>
		<comments>http://www.bradywhite.net/2004/11/14/penner-tweens-tutorial/#comments</comments>
		<pubDate>Sun, 14 Nov 2004 23:02:43 +0000</pubDate>
		<dc:creator>Brady White</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[motion tweens]]></category>
		<category><![CDATA[penner tweens]]></category>

		<guid isPermaLink="false">http://bradywhite.net/?p=13</guid>
		<description><![CDATA[Penner Tweens, created by <a href="http://www.robertpenner.com">Robert Penner</a>, use built-in Macromedia Flash MX 2004 classes to script tweens.  This is the touch of class that adds to any flash application / navigation / presentation.   To set it up, you define an ease type, then apply the ease type to a Tween object.]]></description>
			<content:encoded><![CDATA[<p>Penner Tweens, created by <a href="http://www.robertpenner.com">Robert Penner</a>, use built-in Macromedia Flash MX 2004 classes to script tweens.  This is the touch of class that adds to any flash application / navigation / presentation.   To set it up, you define an ease type, then apply the ease type to a Tween object.</p>
<p>[FLASH] /wordpress/swfs/clickdemo.swf , 400, 150 [/FLASH]</p>
<p>~a~</p>
<p><a href="/wordpress/tuts/PennerTweens.zip">Download Source Files</a></p>
<p>Create a new flash document (File -> New&#8230; -> Flash Document)</p>
<p><img src="/wordpress/tutImages/pennerTweens/newFlashDocument.gif" alt="Flash New Document" /></p>
<p>Double-Click &#8216;Layer 2&#8242; and label it &#8220;A&#8221; (for Actions).  We will place all actionscript on this layer.</p>
<p>Create a new layer (Insert -> Timeline -> Layer). Double-Click &#8216;Layer 1&#8242; and label it &#8220;mc&#8221; (for movieclips).</p>
<p><img src="/wordpress/tutImages/pennerTweens/timeline1.gif" alt="Our new timeline" /></p>
<p>Draw a box using the Rectangle Tool (hotkey is &#8216;R&#8217;) near the top left of the Stage.</p>
<p>Double-Click on your new box.  Now Right-Click on your box and select &#8220;Convert to Symbol&#8230;&#8221;.</p>
<p>In the &#8216;Name&#8217; field put &#8220;m_box&#8221;.  In the &#8216;Behavior&#8217; radio button group, select &#8220;Movie clip&#8221;. Press &#8216;OK&#8217;.</p>
<p><img src="/wordpress/tutImages/pennerTweens/convertSymbol.gif" alt="Convert symbol" /></p>
<p>Having your m_box on the stage still selected, in the &#8216;Properties&#8217; toolbar, where there is a white field that has &#8221; <instance Name> &#8221; enter &#8220;box_mc&#8221;.  Notice that the instance name on the stage is different than the instance name on the stage.  We use the &#8220;_mc&#8221; naming convention for actionscript hints in our code.</p>
<p><img src="/wordpress/tutImages/pennerTweens/instanceName.gif" alt="Instance name on stage" /></p>
<p>Next, select Frame &#8216;1&#8242; in the &#8216;A&#8217; Layer. Open up your actions panel (Window -> Development Panels -> Actions or using hotkey &#8216;F9&#8242;). Copy and paste this code into the &#8216;Actions&#8217; panel.<br />
<code><br />
var easeType = mx.transitions.easing.Regular.easeOut;<br />
myTween = new mx.transitions.Tween(box_mc, "_y", easeType, 0, 300, 30);<br />
</code><br />
<img src="/wordpress/tutImages/pennerTweens/actions.gif" alt="Actionscript in Actions panel" /></p>
<p>Now you might be asking what this just did.  Well lets take an indepth look at the code defintion of the Tween object.<br />
(do not enter this code into your movie):<br />
<code><br />
Tween(myMovie:MovieClip, myProperty:Property, easeType,  startValue:Number, endValue:Number, frames(or seconds), secondsSet:Boolean);<br />
</code></p>
<p><strong>myMovie:MovieClip</strong> &#8212; Targets the Instance of a Movieclip on the stage.<br />
<strong>myProperty:Property</strong> &#8212; Selects the property of the Movieclip on the stage to tween. (I.E. _x, _width, _alpha, etc)<br />
<strong>easeType as (Parent.Child) </strong>&#8211; Your tween definition set up as a variable.  SetParent Types (Back, Bounce, Elastic, None, Regular, Strong).  Child Types (easeIn, easeOut).  (i.e. Bounce.easeOut).<br />
<strong>startValue:Number</strong> &#8212; Starting value of property to tween. For more advanced tweens, try (box_mc._y) to get the current starting Y position of the targeted Movie Clip.<br />
<strong>endValue:Number</strong> &#8212; Starting value of property to tween.<br />
<strong>frames(or seconds)</strong>  &#8212; Number of frames to tween over, or number of seconds to tween over.<br />
<strong>secondsSet:Boolean</strong> &#8212; Optional value, defaults to false.  When set to true, uses seconds instead of frames to tween over.</p>
<p>Save your document (File -> Save)</p>
<p>Test your movie (Control -> Test Movie or hotkey &#8220;Ctr-Enter&#8221;)</p>
<p>Your box should go from _y position 0 to 300.  Now try out variations of properties and movieclips and tweens.</p>
<p>For smoother framerate, try changing the framerate to 31 fps.  To do so, go to Modfiy -> Document&#8230; .  In the Frame rate input box, type in &#8216;31&#8242;.  Press &#8216;OK&#8217;.  Try your movie again.</p>
<p><img src="/wordpress/tutImages/pennerTweens/documentFPS.gif" alt="Change Frames Per Second (FPS)" /></p>
<p>To try out my click demo, replace your current code on you &#8220;A&#8221; Layer with this code:<br />
<code><br />
someListener = new Object();<br />
someListener.onMouseDown = function () {<br />
	var easeType = mx.transitions.easing.Elastic.easeOut;<br />
	myTweenY = new mx.transitions.Tween(box_mc, "_y", easeType, box_mc._y,_root._ymouse, 60);<br />
	myTweenX = new mx.transitions.Tween(box_mc, "_x", easeType,  box_mc._x, _root._xmouse, 60);<br />
};<br />
Mouse.addListener(someListener);<br />
</code></p>
<p>For more easing variations, view the folder on your computer >><br />
..Program Files/Macromedia/Flash MX 2004/en/First Run/Classes/mx/transitions</p>
<p>Try out Rober Penner&#8217;s  examples at:<br />
<a href="http://www.robertpenner.com/easing/easing_demo.html">Robert Penner&#8217;s Easing Demo</a></instance></p>
<p><a href="/wordpress/tuts/PennerTweens.zip">Download Source Files.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.bradywhite.net/2004/11/14/penner-tweens-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
