<?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; AS2 Tutorials</title>
	<atom:link href="http://www.actionscriptartist.com/category/as2-flash-8-tutorials/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>
		<item>
		<title>The Tank: Part 2: Rotating and Shooting the Cannon</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-2-rotating-and-shooting-the-cannon/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-2-rotating-and-shooting-the-cannon/#comments</comments>
		<pubDate>Sun, 17 Sep 2006 17:02:06 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=61</guid>
		<description><![CDATA[In this Flash tutorial you will learn how to make the cannon on the tank rotate wherever the mouse is pointing and shoot whenever the left mouse button is clicked.  Topics covered in this tutorial: mouse angle detection, onMouseDown event, duplicateMovieClip, rotation and actionscript controlled motion.

Click here to see the completed swf file.
Begin by [...]]]></description>
			<content:encoded><![CDATA[<p>In this Flash tutorial you will learn how to make the cannon on the tank rotate wherever the mouse is pointing and shoot whenever the left mouse button is clicked.  Topics covered in this tutorial: mouse angle detection, onMouseDown event, duplicateMovieClip, rotation and actionscript controlled motion.</p>
<div align="center"><EMBED src="http://www.actionscriptartist.com/files/flash/tankPt2.swf" qulity=high bgcolor=#6D4201  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/tankPt2.swf">here</a> to see the completed swf file.</p>
<p>Begin by downloading the following Flash file: <a href="http://www.actionscriptartist.com/files/flash/tankPart2_rotation_artillery.fla">tankPart2_rotation_artillery.fla</a>.  This file contains all the movieclips that you will need without the actionscript.  We will fill that in during the tutorial.</p>
<p><strong>Edited</strong>: Here is the <a href="http://www.actionscriptartist.com/files/flash/tank_part2_final.fla">source file</a>.</p>
<p>This tutorial is broken up into two main sections:<br />
i. Cannon Movement</p>
<p>ii. Firing the Cannon<br />
<strong><br />
Cannon Movement</strong></p>
<p>**The method we are going to use to detect the mouse angle is only approximate.  Its not perfect, but it is fine for our purposes and for most games or movies that you can create with it.</p>
<p>First familiarize yourself with the project file.  Notice the cannon movieclip is named &#8220;cannon_mc&#8221;.  There is also an invisible movieClip named &#8220;mouseTarget&#8221; Also notice that we have 3 frames in the timeline.  In the &#8220;Cannon Actions&#8221; layer we have 3 keyframes.</p>
<p>1. In the first keyframe place the following action:</p>
<pre lang="actionscript">
startDrag("mouseTarget", true);
</pre>
<p>This action allows the movieClip &#8220;mouseTarget&#8221; to follow the mouse around wherever it goes.  This is how we will be able to detect the mouse&#8217;s position relative to the tank, think of this as the crosshairs of where you will shoot.</p>
<p>2. In the 3rd keyframe place the following action:</p>
<pre lang="actionscript">
gotoAndPlay(2);
</pre>
<p>By placing this action is frame 3 we have created a continuous loop between the 2nd and 3rd frames.  This is necessary so that we can continuously recalculate the mouse&#8217;s position.</p>
<p>3. We calculate the mouse angle in the 2nd keyframe.  All of the following actions will be placed in the 2nd keyframe of the &#8220;Cannon Actions&#8221; layer.</p>
<p>i. First we figure out the x and y distances of the mouseTarget from the tank.</p>
<pre lang="actionscript">
// calculate the distance from tank
// to mouse click in terms of (x,y)
xDistance = mouseTarget._x - tank_mc._x;
yDistance = mouseTarget._y - tank_mc._y;
</pre>
<p>ii. Next we calculate the normalisation factor and use it to determine the mouse angle.  I am not going to get into all the details of this mathmatical equation.  Basically, normalization is the process of breaking up two values into relative proportions of each other.  We use normalisation to figure out the approximate percentage of rotation within each of the four quadrants surrounding the tank.  All you need to know is that this formula works in calculating the approximate mouse angle (its not exact, but good enough for this tutorial).  Without further ado here is the code:</p>
<pre lang="actionscript">
    // the normalisation factor is equal to
    // the sum of the absolute distances of
    // x and y.
    normalise = Math.abs(xDistance) + Math.abs(yDistance);

    // determine the direction
    if ((xDistance >= 0) &#038;&#038; (yDistance >= 0)) {
        mouseDirection = 90 * (yDistance/normalise);
    } else if ((xDistance <= 0) &#038;&#038; (yDistance >= 0)) {
        mouseDirection = -90 * (xDistance/normalise) + 90;
    } else if (((xDistance)<=0) &#038;&#038; ((yDistance)<=0)) {
        mouseDirection = -90 * (yDistance/normalise) + 180;
    } else {
        mouseDirection = 90 * (xDistance/normalise) + 270;
    }
</pre>
<p>Okay, thats it for the "Cannon Movement" section.  Run your movie and see if it worked!</p>
<p><strong>Firing the Cannon</strong></p>
<p>To uncover the bullet movieClip, first hide the tank and cannon layers ( do this by clicking the on the first dot next to the layer name).  Now you should see a little green dot (our bullet).  I have named this movieClip "bullet_new".  The basic concept behind making the bullet fire is to duplicate the bullet_new movieClip and make it move towards where the mouse was click.  Okay lets get started.</p>
<p>i. Click on the second frame of the "Cannon Actions" layer and add the following:</p>
<pre lang="actionscript">
// set mouse values for artillary

// initially these will be "nil,nil" before
// this frame loads
mouse_x = mouseTarget._x;
mouse_y = mouseTarget._y;
</pre>
<p>These coordinates will be used to tell the bullet where to go.  The reason we put them in the second frame is so that the initial bullet_new movieClip will always keep its original coordinates.</p>
<p>ii. Click on the first frame of the "Bullet Actions" layer and add the following actionscript:</p>
<pre lang="actionscript">
    // initialize newBullet which will
    // be used to denumerate the new movieclips
    // created below.
    X = 0;

    onMouseDown = function() {
        X++;
        duplicateMovieClip(”_root.bullet_new”, “_root.bullet_new.bullet” add X, X);
    }
</pre>
<p>This basically creates a new movieClip named "bullet_new.bulletX".  Each mouse click creates a new movieclip.  The "X++" is short for "X = X + 1".  So each new movieclip has a unique name and identifier.  Review <a href="http://www.macromedia.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary517.html">duplicateMovieClip in the ActionScript Dictionary</a> if you don't understand this.</p>
<p>iii. Now for the actionscript to make the "bullet_new" movieclip move.  Click on the &#038;"bullet_new" movieclip and insert the following actions onto the movieclip:</p>
<pre lang="actionscript">
    // when the movieclip loads
    onClipEvent(load){
        // Set the variables up to be equal to where mouse is when clicked.
        xDest = _root.mouse_x;
        yDest = _root.mouse_y;

        // Set the alpha visibility to be full.
        this._alpha = 100;
    }

    onClipEvent(enterframe){
        // if the xDest has been changed then
        // move bullet from the cannon to
        // the mouse location
        if ((this._x != xDest)) {
            // move bullet towards mouse click
            this._x += (xDest-this._x)*.1;

            // slowly make bullet disappear
            this._alpha -= 4;
        }

        // See if the yDest has been changed
        if (this._y != yDest) {
            this._y += (yDest-this._y)*.1;
            this._alpha -= 4;
        }
    }
</pre>
<blockquote><p>
// when the movieclip loads</p>
<p>onClipEvent(load){</p>
<blockquote><p>    // Set the variables up to be equal to where mouse is when clicked.<br />
    xDest = _root.mouse_x;<br />
    yDest = _root.mouse_y;</p>
<p>	// Set the alpha visibility to be full.<br />
    this._alpha = 100; </p>
</blockquote>
<p>}</p>
<p>onClipEvent(enterframe){</p>
<blockquote><p>	// if the xDest has been changed then<br />
	// move bullet from the cannon to<br />
	// the mouse location<br />
    if ((this._x != xDest))  {</p>
<blockquote><p>	// move bullet towards mouse click</p>
<p>		this._x += (xDest-this._x)*.1;</p>
<p>		// slowly make bullet disappear<br />
		this._alpha -= 4;  </p>
</blockquote>
<p>    }</p>
<p>// See if the yDest has been changed<br />
    if (this._y != yDest) {</p>
<blockquote><p>    	this._y += (yDest-this._y)*.1;<br />
		this._alpha -= 4;</p>
</blockquote>
<p>    }</p>
</blockquote>
<p>}</p>
</blockquote>
<p>Okay, thats it!  Now test your movie and see if it works.</p>
<p>Add-on to the Tank: Part 1: Basic Movement</p>
<p>If you add all of the code from the last part, then making this work for the movable tank is quite simple.</p>
<p>i. Add the following code to each of your LEFT and RIGHT arrow key press functions:</p>
<blockquote><p>_root.bullet_new._x = _root.cannon._x; </p>
</blockquote>
<p>ii. Add the following code to each of your UP and DOWN arrow key press functions:</p>
<blockquote><p>_root.bullet_new._y = _root.cannon._y; </p>
</blockquote>
<p>iii. Delete the SPACEBAR key press function and of course use the new mouseDown function from Part 2 and delete the one from Part 1.</p>
<p>Thats it, we're done!  Here's the final result:</p>
<div align="center"><EMBED src="http://www.myflashresource.com/wp-admin/swfs/tank_part2_final.swf" quality=high bgcolor=#6D4201  WIDTH=468 HEIGHT=200 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></div>
<p>Thank-you for participating in this Flash tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-2-rotating-and-shooting-the-cannon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Tank: Part 1: Basic Movement and Artillery</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-1-basic-movement-and-artillery/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-1-basic-movement-and-artillery/#comments</comments>
		<pubDate>Sun, 10 Sep 2006 13:00:04 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=56</guid>
		<description><![CDATA[This tutorial will be presented in a step-by-step format.Click here to preview the finished project.  The completed source file is here
1. Download the source file move_tank.fla, extract and open the fla file. In this file you will find all the creative assets involved in this project. However there will be no actionscript in the [...]]]></description>
			<content:encoded><![CDATA[<p>This tutorial will be presented in a step-by-step format.<a href="http://www.actionscriptartist.com/files/flash/tank_move_final.swf" target="_blank">Click here</a> to preview the finished project.  The completed source file is <a href="http://www.actionscriptartist.com/files/flash/tank_move_final.fla">here</a></p>
<p>1. Download the source file <a href="http://www.actionscriptartist.com/files/flash/tank_move.fla">move_tank.fla</a>, extract and open the fla file. In this file you will find all the creative assets involved in this project. However there will be no actionscript in the file. This is what we will be creating in this tutorial.</p>
<p>2. Okay so now you have the opened file ready to go. Take a look around at what is contained in the flash document. On the stage there are two movieclips, the tank which is named &#8220;tank_mc&#8221; and the bullet which is named &#8220;bullet_mc&#8221;.</p>
<div style="text-align: center"><img src="http://www.actionscriptartist.com/files/tank01.jpg" /></div>
<p>If you double click on the tank you will see its contents. There is the tank graphic and the two tank track movieclips.</p>
<div style="text-align: center"><img src="http://www.actionscriptartist.com/files/tank02.jpg" /></div>
<p>Go back to the main timeline. The last element we will look at is the bullet movieclip which is aptly named &#8220;bullet_mc&#8221;. Double click on it and have a look at its contents. Its simply a motion tween of a bullet going forward and then disappearing at the end. The disappearing tween is done with the alpha property of the bullet movieclip.</p>
<p>Now that you are familiar with all the graphical parts of our project. We can move on.</p>
<p>3. Go back to the main timeline and take a look at the layer named &#8220;Actions&#8221;. This is where all your actions for the entire project will be located.</p>
<p>**Having all the actions in one convenient place is the industry standard and if you don&#8217;t normally do this then you probably should start. The reason for this is that it makes it much easier to go back and edit your project.</p>
<p>Click on the first frame of the actions tabs and open the actionscript window (Shortcut key: F9).</p>
<p>i. We&#8217;ll start with the inital conditions. Initially we want the bullet on the stage but we don&#8217;t want to see it. So we put the bullet_mc at frame 10 where it&#8217;s invisible.</p>
<pre lang="actionscript">
// initial conditions

bullet_mc.gotoAndStop(10);
</pre>
<p>ii. Okay now for the fun stuff. The following is how you will control your tank with the arrow keys. We start by creating an event, namely the &#8216;enterFrame&#8217; event. This means that the commands within this statement will be active as soon as this movie loads up and will continue to me active unless we delete the movieclip. First, we will have to define some initial conditions pertaining to the speed of the movement of the tank.</p>
<pre lang="actionscript">
    tank_mc.onEnterFrame = function() {
      // forward and backward motion speed of the tank
      tankSpeed = 5
      // side to side movement of the tank
      sideSpeed = 2
    }
</pre>
<p>Now for the key press movement. We will start with the right arrow key which will control forward movement.</p>
<pre lang="actionscript">
    tank_mc.onEnterFrame = function() {
        // forward and backward motion speed of the tank
        tankSpeed = 5

        // side to side movement of the tank
        sideSpeed = 2

        // if key is down and key = right arrow (Key.RIGHT)
        // then increase the tanks x position
        // by 5 (tankSpeed).
        if (Key.isDown(Key.RIGHT)) {
            this._x+= tankSpeed;
        }
    }

    tank_mc.onEnterFrame = function() {
        // forward and backward motion speed of the tank
        tankSpeed = 5

        // side to side movement of the tank
        sideSpeed = 2

        // if key is down and key = right arrow (Key.RIGHT)
        // then increasethe tanks x position
        // by 5 (tankSpeed).
        if (Key.isDown(Key.RIGHT)) {
            this._x+= tankSpeed;
        }

        // if key is down and key = left arrow (Key.LEFT)
        // then increase the tanks x position
        // by 5 (tankSpeed).
        if (Key.isDown(Key.LEFT)) {
            this._x -= tankSpeed;
        }

        // if up arrow is pressed then move tank
        // up 2 px (sideSpeed)
        if (Key.isDown(Key.UP)) {
            this._y -= sideSpeed;
        }

        // if down arrow is pressed then move tank
        // down 2 px
        if (Key.isDown(Key.DOWN)) {
            this._y += sideSpeed;
        }
    }
</pre>
<p>Okay now press &#8220;ctrl + enter&#8221; to run your movie. Notice that you can press more than one arrow at a time and it responds. This is because we used a separate if statement for each arrow key. Had we nested them all in one &#8220;if else if&#8221; statement we would not have this functionality.</p>
<p>iii. Finally, its time to make our tank fire some artillery. There are two different ways we will make this happen. One is with the &#8220;spacebar&#8221; and the other is with a left-mouse click. We&#8217;ll start with the &#8220;spacebar&#8221; shooting mechanism. Its basically the same as the arrow key presses.</p>
<p>** This goes in the tank_mc.onEnterFrame with the key presses.</p>
<pre lang="actionscript">
    // if spacebar (Key.SPACE) is pressed then
    // play bullet animation.
    if (Key.isDown(Key.SPACE)) {

        // This code puts the bullet_mc at the end of the
        // cannon barrel.
        bullet_mc._x = tank_mc._x + 22;
        bullet_mc._y = tank_mc._y;

        // this plays the bullet animation. I start at frame 3
        // because then I get the bullet in motion instead
        // of it starting stationary.
        bullet_mc.gotoAndPlay(3);
    }
</pre>
<p>Now for the mouse click artillery. The following code uses an event called onMouseDown. OnMouseDown executes whenever the mouse is clicked.</p>
<pre lang="actionscript">
    // while left mouse butting is pressed
    onMouseDown = function() {
      // establish bullet position
      bullet_mc._x = tank_mc._x + 22;
      bullet_mc._y = tank_mc._y;

      // play the bullet animation. The reason I start at
      // frame 2 here is because this action is slightly less
      // responsive than the key press function.
      bullet_mc.gotoAndPlay(2);
    }
</pre>
<p>Alright thats it! Press ctrl+enter to run your movie and see how it all turned out. Stay tuned for the next tank movement tutorial which will be all about rotating the canon and shooting in different directions. The artillery is greatly improved upon in Part 2.</p>
<p>If you enjoyed this tutorial then continue on to <a href="http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-2-rotating-and-shooting-the-cannon">The Tank: Part 2: Rotating and Shooting the Cannon</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/the-tank-part-1-basic-movement-and-artillery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Glowing Text Effect</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/glowing-text-effect/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/glowing-text-effect/#comments</comments>
		<pubDate>Thu, 15 Jun 2006 01:29:37 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=50</guid>
		<description><![CDATA[  In this Flash tutorial you will learn how to make text glow (this effect will also work for anything drawn in Flash).  The glowing edges around the text will ease in and ease out in this animations.  Topics include: soften fill edges, alpha control, and basic tweening.  No actionscript involved [...]]]></description>
			<content:encoded><![CDATA[<p>  In this <strong>Flash tutorial</strong> you will learn how to make text glow (this effect will also work for anything drawn in Flash).  The glowing edges around the text will ease in and ease out in this animations.  Topics include: soften fill edges, alpha control, and basic tweening.  No <strong>actionscript</strong> involved and source file is included.</p>
<div align="center"><EMBED src="http://www.actionscriptartist.com/files/flash/glowingtext.swf" qulity=high bgcolor=#000000  WIDTH=468 HEIGHT=75 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></div>
<p>The source file for this tutorial is <a href="http://www.actionscriptartist.com/files/flash/glowingtext.fla">here</a>.</p>
<p>This <strong>Flash tutorial</strong> is presented in a step-by-step format.  Feel free to use your own settings when it comes to background and text colour.  I will only show what I used.</p>
<p>1. Open a new Flash document (shortcut key: CTRL+N).  Name you first layer ‘text’. </p>
<p>2. Change the background colour to black.</p>
<p>3. Type in some text, use a fairly large font (I used 38px), and change the colour to white.</p>
<p>4. Break apart the text.  Do this by selecting the text, right-click and select Break Apart (shortcut key: CTRL+B).  Do this twice until the text has turned into pixels.</p>
<p>5. Create a new layer below the current layer and name it ‘Glowing Text’.  Copy your text and paste it in place on the new layer.  Paste in place means that you paste it in the exact same spot as the one you copied.  The shortcut key for this is CTRL+SHIFT+V.</p>
<p>6. Lock the ‘text’ layer and select the text in the ‘Glowing Text’ layer.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/glow01.jpg" alt="Flash Tutorial" /></div>
<p>7. With the text selected, goto Modify>Shape>Soften Fill Edges Use the following settings: Distance: 10px, Number of Steps: 15, Direction: Expand.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/glow02.jpg" alt="Flash Tutorial" /></div>
<p>8. Now you should be able to see the glowing part around the text.  Select all of the text again and convert it to a movieclip symbol.  Goto Modify>Convert to Symbol (shortcut key: F8).</p>
<p>9. Insert keyframes in the following places in the ‘Glowing Text’ layer: frame 10, frame 15, and frame 25.  Use shortcut key F6 to insert these keyframes.</p>
<p>10. Insert the following alpha levels for your movieclip into the corresponding keyframes of the ‘Glowing Text’ layer: frame 1 (alpha=0%); frame 10 (alpha=65%); frame 15 (alpha=65%); frame 25 (alpha=0%).  The alpha proporties is located in the properties panel (also the movieclip must be selected).</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/glow03.jpg" alt="Flash tutorial" /></div>
<p>11. Insert motion tweens between the frame 1 and 10 and between 15 and 25.  To insert a motion tween click anywhere between the two frames that you want the tween and select ‘Motion Tween’ in the Properties panel at the bottom of the screen.</p>
<p>12. Insert a frame on the ‘text’ layer at frame 25.  Right-click on frame 25 and select New Frame.  Your timeline should look like the following:</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/glow04.jpg" alt="Flash Tutorial" /></div>
<p>Run your movie and check out the results and you should have glowing text.  This effect can be used on anything drawn in Flash, just use the soften edges technique and this method.  It could make a good button rollover effect if you set it up properly.  Anyways I hope you enjoyed this Flash tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/glowing-text-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Initiates Action</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/drag-and-drop-initiates-action/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/drag-and-drop-initiates-action/#comments</comments>
		<pubDate>Mon, 24 Apr 2006 18:09:03 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=45</guid>
		<description><![CDATA[In this Flash tutorial you will first create a symbol (object) that you can drag and drop around the screen.  Next you will create a drop zone area that will cause the symbol (object) to react when it is dropped into the target area by performing a hit test.  As always the completed [...]]]></description>
			<content:encoded><![CDATA[<p>In this Flash tutorial you will first create a symbol (object) that you can drag and drop around the screen.  Next you will create a drop zone area that will cause the symbol (object) to react when it is dropped into the target area by performing a hit test.  As always the completed source file is included.</p>
<div align="center"><EMBED  src="http://www.actionscriptartist.com/files/flash/drag_n_drop.swf" quality=high bgcolor=#FFFFFF  WIDTH=468 HEIGHT=80 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></div>
<p>Download the source file: <a href="http://http://www.actionscriptartist.com/files/flash/drag_n_drop.fla">drag_n_drop.fla</a> </p>
<p>This Flash tutorial will be presented in a step-by-step format.  Even though the source file and the example includes two different drop areas, I will only be teaching how to make one of them.  </p>
<p>You should be able to figure out how to make more are completing this Flash tutorial.</p>
<p><strong>Set up the Timeline</strong></p>
<p>1. Open Flash, create a new Flash Document and create three layers labelled (from top to bottom): Actions, drag_me symbol, landing area.</p>
<p><strong>Creating a drag &#8211; able symbol in Flash:</strong></p>
<p>2. On the first frame of the ‘drag_me symbol’ layer, draw whatever it is that you want to be you drag and drop object, I used my cartoon head.  Use the selection tool to select your entire drawing and turn it into a movieclip symbol.  You can do this by clicking Modify>Convert to symbol (or using the shortcut key: F8).<br />
3. Name your movieclip (the instance name) ‘drag_me’.  The instance name is located in the properties panel.  </p>
<div align="center"><img src="http://http://www.actionscriptartist.com/files/flash/drop01.jpg" alt="Flash Tutorial Image" /></div>
<p>4. We have to edit the movieclip, so double-click on the movieclip and you will be in editing mode.  Notice the little crosshairs in the top-left corner of your graphic, we want these to be in the exact middle of your graphic.  So select your graphic and move it until the crosshairs is in the middle.  This is important for when we perform the hit test later.  When your done, go back to the main timeline by double-clicking outside of you graphic.</p>
<p>5. On the first frame of the ‘Actions’ layer.  Add the following actions, which will allow your movieclip to be drag and drop (ed):</p>
<pre lang="actionscript">
    // drag while mouse is pressed.
    drag_me.onPress = function() {
        startDrag(this, false);
    }

    // stop dragging when mouse button is released.
    drag_me.onRelease = function() {
        stopDrag();
    }

    // stop dragging when mouse is released outside,
    // just to make sure the object gets released.
    drag_me.onReleaseOutside = function() {
        stopDrag();
    }
</pre>
<p>Test your movie and see if it works.</p>
<p><strong>Create the landing area</strong></p>
<p>6. On the first frame of the ‘landing area’ layer, draw a landing area.  I used a circle and a square.  After you have drawn the landing area convert it into a movieclip the same way you did in step 2.  Name your movieclip circleHit (instance name) or whatever you want, but I have used circleHit in my source file. You also have to edit this movieclip to make the crosshairs appear in the center on the symbol like you did in step 4.</p>
<p>7.  Now for the tricky part.  You have to create a hit test so that you can perform an action when the ‘drag_me’ clip is dragged into the landing area.  The reason you centered the two movieclips you made is so that when we get their x and y position we will be refering to the center of the movieclip symbol rather than the top left.  The following actionscript will define the target area that we will trigger the actions:</p>
<pre lang="actionscript">
// calculate circle hit area
C_hitLeft_x = circleHit._x - 6;
C_hitTop_y = circleHit._y + 6;
C_hitRight_x = circleHit._x + 6;
C_hitBottom_y = circleHit._y - 6;
</pre>
<p>8. Next we define the conditions for a hit using an if&#8230;then statement in the drag_me.onRelease function:</p>
<pre lang="actionscript">
     drag_me.onRelease = function() {
        stopDrag();

        // if drag_me is in the circle hit area then make it black
        if (this._x < C_hitRight_x &#038;&#038; this._x > C_hitLeft_x &#038;&#038; this._y < C_hitTop_y &#038;&#038; this._y > C_hitBottom_y) {
            this.gotoAndStop(5); // perform some action.
        }
        else {
            this.gotoAndStop(1); // else do nothing
    }
</pre>
<p>In my source file I have made my ‘drag_me’ movieclip a little more diverse.  I basically just change its qualities throughout the timeline so that on Frame 5, I put a stop() action and made the symbol completely black.  That is why my action is this.gotoAndStop(5).  I decided to leave this out of the tutorial because ideally you can perform any action you want at this step, I’ll leave that up to you.  Following is the complete actionscript for this tutorial,  all of these actions should be placed in the first frame of the Actions layer.</p>
<pre lang="actionscript">
    // calculate circle hit area
    C_hitLeft_x = circleHit._x - 6;
    C_hitTop_y = circleHit._y + 6;
    C_hitRight_x = circleHit._x + 6;
    C_hitBottom_y = circleHit._y - 6;

    drag_me.onPress = function() {

        startDrag(this, false);

    }

    drag_me.onRelease = function() {

        stopDrag();
        // if drag_me is in the circle hit area then make it black
        if (this._x < C_hitRight_x &#038;&#038; this._x > C_hitLeft_x &#038;&#038; this._y < C_hitTop_y &#038;&#038; this._y > C_hitBottom_y) {

            this.gotoAndStop(5);

        }
        else {

            this.gotoAndStop(1);

        }

    }

    drag_me.onReleaseOutside = function() {

        stopDrag();

    }
</pre>
<p>Your done, thank-you for participation in this Flash 8 tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/drag-and-drop-initiates-action/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Crosshairs Rollover Text Effect</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/crosshairs-rollover-text-effect/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/crosshairs-rollover-text-effect/#comments</comments>
		<pubDate>Mon, 10 Apr 2006 01:07:47 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=47</guid>
		<description><![CDATA[In this Flash tutorial you will create a rollover effect using masks.  The crosshairs will follow your mouse cursor as you move over the text.  Topics involved: startDrag actionscript, masking, drawing a target using radial gradient tool.  Source file included.

Here is the source file for this Flash tutorial.
This tutorial is presented in [...]]]></description>
			<content:encoded><![CDATA[<p>In this Flash tutorial you will create a rollover effect using masks.  The crosshairs will follow your mouse cursor as you move over the text.  Topics involved: startDrag actionscript, masking, drawing a target using radial gradient tool.  Source file included.</p>
<div align="center"><EMBED  src="http://www.actionscriptartist.com/files/flash/textRollover.swf" quality=high bgcolor=#FFFFFF  WIDTH=468 HEIGHT=60 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED></div>
<p>Here is the <a href="http://www.actionscriptartist.com/files/flash/textRollover.fla">source file</a> for this Flash tutorial.</p>
<p>This tutorial is presented in a step-by-step format.</p>
<p>1. Open a new Flash document (shortcut key: CTRL+N).  </p>
<p>2. Name your first layer ‘actions’.</p>
<p>3. Place the following actionscript into the first frame of the ‘actions’ layer.</p>
<pre lang="actionscript">
// allow the movieClip ‘mouse_target’ follow the mouse cursor.
startDrag(mouse_target, true);
</pre>
<p>Note:  I am using Flash 8 to create this tutorial, your version of Flash may require different notation.  If you get an error with this script then try it without the double-quotes(“) around the movieClip name ‘mouse_target’.</p>
<p>4. Create 3 more layers below the ‘actions’ layer and name them as follows from top to bottom: ‘text mask’; ‘crosshairs’;’text background’.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/roll01.jpg" alt="" /></div>
<p>5. Goto the ‘text mask’ layer and turn it into a mask.  You can accomplish this by right-clicking on the layer name and chosing the ‘Mask’ option.  Notice how this made the ‘crosshairs’ layer move over.  This means that whatever you put in the ‘text mask’ layer will only show up if it is covered by the movieClip that will be located in the ‘crosshairs’ layer.</p>
<p>\</p>
<p>6. Now unlock the ‘text mask’ layer and type in the text that you want to use for this movie.  The bigger the text the more you will be able to see this effect.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/roll02.jpg" alt="" /></div>
<p>7. Break-apart the text twice so that all that remains is a bitmap.  Accomplish this by right-clicking on the text and choosing ‘Break Apart’ (shortcut key: CTRL+B).</p>
<p>8. Highlight all of the text and copy it, then paste it in place on the ‘text background’ layer so that it is in the exact same spot as the copied text.  Do this by right-clicking on the highlighted text and choosing ‘Copy’ (shortcut key: CTRL+C).  Then on the ‘text background’ layer right-click on the stage and select ‘Paste in Place’ (shortcut key: CTRL+SHIFT+V). </p>
<p>9. Draw the crosshairs in the ‘crosshairs’ layer and turn it into a movieClip labeled ‘mouse_target’.  I will outline how I drew my crosshairs.</p>
<blockquote><p>
i. Start by drawing a perfect circle with no border.  Hold shift will drawing to make a perfect circle.  Choose a size that is slightly larger than the height of your text.  You can change the overall size later if you want.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/roll03.jpg" alt="" /></div>
<p>ii. Highlight your circle and click on the paint bucket in the color chooser panel.  Now choose ‘Radial’ under the ‘Type’ heading.  Use the following settings.</p>
<div align="center"><img src="www.actionscriptartist.com/files/roll04.jpg" alt="" /></div>
<p>iii. For the circle in the middle, I choose the eraser tool and set it to the biggest circle setting, then click it once in the exact middle of you circle.</p>
<p>iv. The crosshairs were make by highlighting a horizontal line in the middle of the circle and pressing delete, do the same for the vertical line.</p>
<p>v. The outer black circle was made outside of the main circle and then moved over top of the existing circle.  Make this slightly smaller then the main circle.  I used line width 2 and no fill, only outline.  </p>
<p>vi. Highlight the whole crosshairs drawing and turn it into a movieClip.  Goto Modify>Convert to Symbol and select ‘Movie clip’.  Label this movieClip with the name ‘mouse_target’.  Double-click on the movieClip to edit it.  Now highlight the entire drawing and move it so that the center of your drawing is on the center of this movie clip (denoted as a small crosshair).</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/roll05.jpg" alt="" /></div>
</blockquote>
<p>Congratulations you’ve successfully completed this Flash tutorial!  Run your movie to see the results.  Let me know how you did!  Tutorial is presented as is, if you have trouble with it, then try and try again, thats how you learn!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/crosshairs-rollover-text-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash Plugin Detection in Flash 8</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/flash-plugin-detection-in-flash-8/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/flash-plugin-detection-in-flash-8/#comments</comments>
		<pubDate>Tue, 07 Mar 2006 15:10:45 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=52</guid>
		<description><![CDATA[Flash plugin detection is very easy to implement in Flash 8.  Its actually built-in.  In this tutorial I will show you how to activate Flash plugin detection for whatever version of Flash that your Flash document requires.  
This Flash tutorial will be presented in a step-by-step format:
1. Open the Flash document that [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Flash plugin detection</strong> is very easy to implement in Flash 8.  Its actually built-in.  In this tutorial I will show you how to activate Flash plugin detection for whatever version of Flash that your Flash document requires.  </p>
<p>This <strong>Flash tutorial</strong> will be presented in a step-by-step format:</p>
<p>1. Open the <strong>Flash</strong> document that you want to insert Flash plugin detection on or create a document.<br />
2. Go to Publish Settings.  Click File>Publish Settings (shortcut key: CTRL+SHIFT+F12).<br />
3. In the Formats tab, make sure that <strong>Flash</strong> (.swf) and HTML (.html) are checked.  Click on the HTML tab.</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/flash8det01.jpg" alt="Flash Plugin Detection" /></div>
</p>
<p>4. Click the box next to <strong>Detect Flash Version</strong>.  Select the version you require for your movie (the default is Version 8 ).  </p>
<div align="center"><img src="http://www.actionscriptartist.com/files/flash8det02.jpg" alt="" /></div>
</p>
<p>5. Click Publish at the bottom of the window and your done.  </p>
<p>The <strong>Flash plugin detection</strong> script is located in the HTML file that was created when you published your movie.  If you want to use the <strong>Flash plugin detection</strong> in a different HTML file then take the scripts between the <body> tags from your original HTML file and put them into your new HTML file (between the <body> tags). </p>
<p>Thank-you for participating in this Flash Tutorial.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/flash-plugin-detection-in-flash-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Gradient Sweep Photo Effect</title>
		<link>http://www.actionscriptartist.com/as2-flash-8-tutorials/gradient-sweep-photo-effect/</link>
		<comments>http://www.actionscriptartist.com/as2-flash-8-tutorials/gradient-sweep-photo-effect/#comments</comments>
		<pubDate>Fri, 03 Feb 2006 17:10:35 +0000</pubDate>
		<dc:creator>Anders</dc:creator>
				<category><![CDATA[AS2 Tutorials]]></category>

		<guid isPermaLink="false">http://www.actionscriptartist.com/?p=54</guid>
		<description><![CDATA[This flash 8 tutorial will be presented in a step-by-step format.  The source file is here .
1. Open Flash.  Create a new document (CONTROL + N).  Make the stage slightly bigger than the photo you want to use.  Also make the background color of the stage black (or whatever color you [...]]]></description>
			<content:encoded><![CDATA[<p>This flash 8 tutorial will be presented in a step-by-step format.  The source file is <a href="http://www.actionscriptartist.com/files/flash/gradientPhoto_effect.fla">here</a> .</p>
<p>1. Open <strong>Flash</strong>.  Create a new document (CONTROL + N).  Make the stage slightly bigger than the photo you want to use.  Also make the background color of the stage black (or whatever color you want, I&#8217;m using black).</p>
<p>2. Click on the first layer and name it image.  Import an image of your choice (goto File>Import>Import to Stage or just press CONTROL + R).  Place the image within the boundaries of the stage.<br />
3. Create a new layer above the image layer and name it rectangle.  Now draw a black rectangle without an outline approximately 2X the width of the image.  You may have to zoom out (View>Zoom Out or press CONTROL + -) to make this easier.</p>
<p>4. Click on the rectangle and turn it into a movieclip symbol(Modify>Convert to Symbol or press F8).  Double-click on the rectangle movieclip to edit it.  With the rectangle selected change the color setting to match the following:</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/gradient01.jpg" alt="Flash Gradient" /></div>
<p>5. Now double-click somewhere outside of the rectangle to return to the main timeline.  Place the rectangle over top of the image so that the solid black part covers the entire picture.  Now insert a keyframe in the rectangle layer at frame 12.  Also insert the actionscpript: stop(); on this frame. </p>
<p>6. At frame 12 of the rectangle move the rectangle movieclip to the left until it no longer covers the image at all.  Now right-click anywhere between frame 1 and frame 12 of the rectangle layer and select motion tween.  This will create a tween that makes the rectangle move from frame 1 to frame 12.</p>
<p>7. Now click on the 12 frame of the image layer and insert a frame (right-click and select New Frame or press F5).  Your timeline should look like this:</p>
<div align="center"><img src="http://www.actionscriptartist.com/files/gradient02.jpg" alt="Flash Gradient Timeline" /></div>
<p>Run your movie, because your done!  I have only shown you how to implement the gradient effect one way (from right to left).  I&#8217;ll leave it to you to figure out how to make the gradient effect do other more interesting things.  Thanks for participating in this Flash Tutorial.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.actionscriptartist.com/as2-flash-8-tutorials/gradient-sweep-photo-effect/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
