<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Actionscript Artist &#187; Add new tag</title>
	<atom:link href="http://www.actionscriptartist.com/tag/add-new-tag/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.actionscriptartist.com</link>
	<description>Design, create, and develop.</description>
	<lastBuildDate>Fri, 14 Aug 2009 20:33:35 +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>Simple but Highly Effective Box Animation</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/simple-but-highly-effective-box-animation/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/simple-but-highly-effective-box-animation/#comments</comments>
		<pubDate>Mon, 06 Nov 2006 03:04:42 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>
		<category><![CDATA[Add new tag]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=64</guid>
		<description><![CDATA[Effect: You have 2 or more boxes (circles, triangles, whatever).  The middle of one is colored, you click on a different box and the middle color slides to the box you clicked with a cool sliding effect (a faded trail).  This effect is highly re-usable and easy to implement with different shapes and [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Effect:</strong> You have 2 or more boxes (circles, triangles, whatever).  The middle of one is colored, you click on a different box and the middle color slides to the box you clicked with a cool sliding effect (a faded trail).  This effect is highly re-usable and easy to implement with different shapes and several of them.  Source code included! Concepts: actionscript animation, button press.<br />
The following effect is as follows:</p>
<div align="center"><EMBED  src="http://www.actionscriptartist.com/files/flash/boxAnimation.swf" quality=high bgcolor=#FFFFFF  WIDTH=468 HEIGHT=300 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></div>
<p>Click <a href="http://www.actionscriptartist.com/files/flash/boxAnimation.fla">here</a> for the source file.</p>
<p>This <strong>Flash Tutorial</strong> will be presented in a step-by-step format.</p>
<p>1. Open <strong>Flash</strong> and create a document with size 400X200.  Create a three layers and label them as follows:</p>
<div align="center"><img src="http://www.actionscriptartist.com/box01.jpg" alt="Flash Tutorial" /></div>
<p>2. In the boxes layer, draw a square with the border a different color than the inside.  I&#8217;ll be using a black border with a green inside.</p>
<p>3. Click on the center of the box (the green part), right-click and select &#8220;copy&#8221; (or just press <ctrl>+c).  Click on the &#8220;square01&#8243; layer and place the square in the same place by right-clicking and selecting &#8220;paste in place&#8221; (or just press <ctrl>+<shift>+v).</p>
<p>4. Lock all layers, except the &#8220;square01&#8243; layer.  Click on the square and turn it into a movieclip.  Do this by clicking of the tab &#8220;insert>new symbol&#8230;&#8221; (or press F8) and select movieclip.  Select the movieclip and put the following actions on the movieclip:</p>
<pre lang="actionscript">

<onClipEvent(enterframe){

  // define the x and y destination by the
  // locX and locY which come from the position
  // of the button clicked.

  xDest = _parent.locX;
  yDest = _parent.locY;

  // change this between 0 - 1 to change the speed
  // of the box.
  speed = 0.2

  // See if the xDest has been changed
  // and move it to new location if it did change.
  if ((this._x != xDest))  {
    this._x += (xDest-this._x)*speed;
  }

  // See if the yDest has been changed
  // and move it to new location if it did change.
  if ((this._y != yDest))  {
    this._y += (yDest-this._y)*speed;
  }
}</pre>
<p>5. Unlock the &#8220;boxes&#8217; layer.  Click on the square (select the outline and the middle).  With the box selected, press F8 to turn it into a symbol and select &#8220;movieclip&#8221;.  Name this movieclip &#8220;box01&#8243;.  Double-click on the box01 movieclip.  Now select just the middle square (not the outline), turn it into a movie.  Now change the alpha property (located on the properties panel, under the heading &#8220;Color:&#8221;) to 0.  </p>
<p>6. Go back to the main timeline and copy the box movieclip a few times and name the other boxes: box02, box03, box04, etc.</p>
<p>7. Go to the &#8220;Actions&#8221; layer and insert the following code:</p>
<pre lang="actionscript">
// box buttons:
// basically we are just defining locX
// and locY to equal the x and y position
// of the box
box01.onPress = function() {
  locX = this._x;
  locY = this._y;
}

box02.onPress = function() {
  locX = this._x;
  locY = this._y;
}

box03.onPress = function() {
  locX = this._x;
  locY = this._y;
}

box04.onPress = function() {
  locX = this._x;
  locY = this._y;
}
</pre>
<p>Now run your movie and you should have a square that moves to the box that you click on.</p>
<p>8. In order to get the fade effect, we will have to add two more layers below the &#8220;square&#8221; layer.  Copy the &#8220;square&#8221; movieclip and paste one copy on each of the two new layers.  Click on each of these copies and change the actionscript in the following way.  Change the speed to a slightly lower number and add the following actionscript after the  code about the speed:</p>
<pre lang="actionscript">
this._alpha = 70;
</pre>
<p>9. Do this again for the last layer, but make the speed slightly lower than the last layer and add this actionscript:</p>
<pre lang="actionscript">
this._alpha = 40;
</pre>
<p>Okay, that&#8217;s all.  This <strong>Flash tutorial</strong> is done.   </p>
<p>Feel free to leave me a comment as to how you liked the tutorial.  Also let me know what other tutorials you would like me to post or even what else you&#8217;d like to see on this site.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/simple-but-highly-effective-box-animation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
