logo
468x60-2-495


  • Home
  • Privacy Policy
  • About
search
Nov 19, 2011 Posted on Nov 19, 2011 in Hints and Tips | 10 comments

Handling Animation States With Starling

The Starling Framework is an AS3 API that mimics the display list, with one crucial difference: it uses Flash Player 11′s new features to render all content by the GPU. In this tutorial, you will learn to add multiple animations to a sprite using the Starling Framework. It assumes a basic understanding of using spritesheets with Starling.


Final Result Preview

Click here to view the demo we’ll be working towards. Click left or right of the monkey to make it walk in that direction; notice how it displays a walking animation when moving and a static frame when standing still.


Initial Code

The entire demo’s source files (in both the initial and final states) are in the source download. However, we’ll mainly be working with one file, MonkeySprite.as, so here are the contents, for reference:

package
{
	import flash.utils.getTimer;

	import starling.animation.Juggler;
	import starling.core.Starling;
	import starling.display.MovieClip;
	import starling.display.Sprite;
	import starling.events.Event;
	import starling.textures.Texture;
	import starling.textures.TextureAtlas;

	public class MonkeySprite extends Sprite
	{
		private var standMovie:MovieClip; // standing animation
		private var mouseX:Number = -1; // location of mouse click on x axis
		private var lastTime:int; // last onFrame movement
		private var movieVector:Vector.<MovieClip>;

		public function MonkeySprite()
		{
			var atlas:TextureAtlas = Assets.getTextureAtlas();

			var standFrames:Vector.<Texture> = atlas.getTextures("monkey_1");
			standMovie = new MovieClip(standFrames, 7 );
			standMovie.loop = true;
			addChild(standMovie);

			pivotX = this.width * 0.5;
			this.addEventListener(Event.ENTER_FRAME, onFrame);
		}		

		public function onFrame(e:Event):void
		{
			if(mouseX == -1)
				return;

			// snap
			if(this.x <= mouseX+5 && this.x >= mouseX-5)
			{
				this.x = mouseX;
			}
			else
			{
				var timeDiff:int = getTimer()-lastTime;
				lastTime += timeDiff;

				if(mouseX > this.x)
				{
					this.x += timeDiff*.15;
				}
				else
				{
					this.x -= timeDiff*.15;
				}
			}
		}

		public function moveToPoint(pointX:Number):void
		{
			mouseX = pointX;
			lastTime = getTimer();
		}
	}
}

Watch the Screencast

Don’t like ads? Download the screencast, or subscribe to Activetuts+ screencasts via iTunes!

Here are the URLs mentioned in the video:

  • The Starling Framework
  • Flash Builder
  • mrdoob’s Hi-ReS-Stats
  • Vicki Wenderlich’s Free Art Archive

Want More Starling Tutorials?

Let us know in the comments!



View full post on Activetuts+

Jul 8, 2011 Posted on Jul 8, 2011 in Hints and Tips | 0 comments

Flash Tips and Best Practices for Designers: Animation

For designers, a huge part of Flash’s appeal lies in its ability to let users add motion and interactivity to just about anything. For most new users, the real Wow! factor comes when they first figure out how to bring things to life using the Flash timeline and ActionScript.

Today we will look at how we can make the most of the tools Flash throws at us for adding animation to our symbols. This can be quite a dense topic to cover given how much the application has grown as a multimedia powerhouse since its early days, but I will try and keep things concise and approachable. For more in-depth coverage, feel free to check out other tutorials on Activetuts+ and I’m sure you will find what you are looking for.

Although this post was written for Flash Professional CS5, most of the tips should work just fine in older versions. I will try and make it a point to highlight wherever something is very specific to the latest version of Flash.


Jargon Busting…

Before we get into the details, let’s take a few minutes to go over some of the jargon we will refer to here. Since most Flash newbies come with very little or no exposure to the concept of moving images, some of these concepts can be a bit daunting to get hold of. It’s best that we cover them upfront before diving deep into the practical aspects of animation and interactivity in Flash.

WTH is FPS?

FPS (or frame rate), very simply, refers to the number of frames rendered every second. Any moving image – animation or video – is a series of still images, projected one after another at a very high speed, causing the illusion of motion. If you have seen a movie reel from the time when they actually used film to shoot videos, you will see that it is simply a strip with a lot of still pictures. How fast the film projector runs through them is what is called FPS.

The default FPS in earlier versions of Flash was 12, which has now been bumped up to 24 over the last couple of versions. This could be because because Flash has progressed from being a pure vector animation tool to the preferred mode of playing videos on the web. Since videos need to play at a minimum of 24 fps to run smoothly, the Flash container also needs to play catch-up. Also, the Flash player has improved drastically now and can render much higher volumes of data needed to play at higher fps without taking a performance hit.

Shape vs Motion tween

Taken directly from the cel animation books, tweening (short for betweening) is the method used to create interim frames between two key frames. For example, if I were to animate a character’s hand going from it’s regular position to pointing to something, I would draw the first and last positions, and then draw the frames in between to simulate motion. How many frames go between the two key frames is defined by the frame rate of the animation and the time in which you need the motion to be completed. Slower movements mean more tween frames, and vice versa.

Flash makes it easy for us by drawing the tween frames itself, unlike what you would do in a traditional hand-drawn animation. Since CS4, there are three distinctly different ways to tween – shape, classic and motion tween. Let’s understand each one a bit:

Shape tween: The most basic type of tween, although you probably won’t be using this too much. You start with a shape and transform it over time. Unless both shapes are not complex and are very similar to each other, you’re probably going to need a lot of practice to get this to work. You can add shape hints to force certain points on a shape to behave during the transformation.

Classic tween: Up until version CS3, this was the primary tweening method in Flash, one that was as loved by everyone as it was hated. You basically take a symbol and modify its properties between keyframes – like size, position, color effect, etc. Since the method depends on two distinct states – one on each keyframe – editing an animated symbol can be quite a tedious task. Something as simple as moving the symbol around needs you to select the symbol on each keyframe and move it exactly the same amount.

Motion tween: By far the biggest upgrade to Flash’s animation capabilities, the motion tween brings After Effects’ much loved motion editor to Flash. The biggest change between the old and the new method is that motion tween is now object-based rather than timeline-based as in the old method. You apply tweens to symbols, with fine control over pretty much any physical aspect of the object through the motion editor panel. Sure, you still apply motion on the timeline, but it is now possible to select a symbol, move it and have its animation carried with it.

Easing

We know that when a ball drops in the real world, its speed is not always the same. It picks up speed as it approaches the ground, then bounces at approximately the same speed and slows down as it reaches the summit where it heads back towards the ground. When you animate objects in Flash, they will transform at an even pace by default. If you’ve been wondering why your animated text entering and exiting the stage feels flat, this is the reason. With easing, you can basically tell Flash to have the motion accelerate or decelerate without having to tweak the position manually at each frame.


New Motion Tween Goodness

One of the biggest issues with old motion tween in Flash – something I didn’t realize till I saw the new one – was that the animation was predominantly timeline-based. You created a keyframe on a layer, placed a symbol on it, added another keyframe a few frames away and modified the symbol. In essence, you were dealing with two distinct instances of a symbol. Moving one made no real different to the instance in the next keyframe. Sure, we all went through hell trying to reposition elements after animating them, but that’s just how Flash played its cards.

Then with CS4 came the motion editor, and things changed forever. Unfortunately, the motion editor is not exactly the best understood part of Flash even after one and a half version increments. Let me take a few moments then and discuss some interesting tidbits about how this thing works, and how you can make it work for you.

Two ways to animate

You can now edit your symbols in two distinct ways to initiate an animation – from inside the motion editor, or directly on the stage like the old days. Each physical parameter of the selected symbol – like x & y co-ordinates, scale, color effects, filters, etc. – is now listed as a row in the motion editor. Simply move to a point in the timeline and change the parameter, and a a keyframe is generated for that parameter. If you like the traditional, visual way of animating things, simply go to a frame and edit the symbol on the stage.

What’s important to understand is that keyframes are now added per parameter, so if you only moved the instance on stage, there will be a keyframe only for the X and/or Y co-ordinates in the motion editor. This provides an immensely broad range of control over animation – something that was impossible to achieve in the older versions of Flash.

Note: You don’t need to explicitly create a keyframe anymore. Just move to a frame, change something about the instance and a keyframe is automatically generated for that parameter alone. For a lot of people, this is a bit of a cultural change; something they find very difficult to get used to. Although you can still manually create a keyframe, I’ve found that unnecessary for the most part.

Finer control over easing

Instead of the single input field and an ‘Edit’ button, you now get an entire row dedicated to easing in the new motion editor. A dotted line spanning all frames of a tween makes it super-easy to see how the easing is working. The included presets are a good way to get started. A curved line means the speed of the animation is gradually increasing or decreasing. A straight line means consistent, even pace. You can create as many eases as you want, and assign different ones to each parameter. Remember that the easing needs to be explicitly assigned to each set of parameters. Unless you do that, your animation will continue to be the same flat movement.

Once you’ve got a hang of how the easing works with the presets, it’s time to get adventurous and try the ‘Custom’ option. What you get here, is a red solid line instead of the dotted one, indicating that you can edit it. Go to a frame and create a keyframe in the ‘Custom’ easing row to add a bezier node in the timeline. You can then use the node handles to edit the curver as you wish.

Quick Tip: If you are not too sure about how easing works but would like to instantly take your animations up several notches, use this rule that I typically go with myself – appearing elements (anything coming into the frame or on stage) work best with a positive ‘Simple (Medium)’ easing at ’50′, while disappearing elements work best with the same easing at ‘-50′. This makes the overall animation feel much smoother and consistent. As a rule, I use easing on virtually anything that moves in my animations.

Motion path editing

When you move an object over time using motion tween, a line appears from the symbol’s registration point showing the start and end point of the movement as well as each of the frames. A seemingly hidden feature here is the fact that this path is like any other line in Flash. You can use the selection and pen tools to modify it the way you would any other path. Click & drag anywhere but the ends of the path (while it is not selected) to convert it to a curve. You can then use the sub-selection tool to edit the bezier handles on the nodes for finer control. Every time you add a keyframe in the motion path, a new bezier curve gets added to the path, which you can then edit as you need it.

Motion path

Quick & easy pseudo-3D animation

If 3D in Flash is what you have always been craving for, but haven’t had the heart to play around the the 3D frameworks like papervision, here’s a quick and dirty way to fake 3D movement in Flash. You can use the new 3D Rotation tool along with the motion editor to make objects rotate in 3 dimensions for that added jazz.

3D Transform tools

3D rotation does not feature in the motion editor unless you actually use it on an object. To do so, select the 3D Rotation Tool, select your object and click & drag one of the three colored lines that appear. Each of the three lines represent an axis – green is Y, red is X and blue is Z. X & Y are typically the ones that will make your object look like it is rotating in 3D space. Get it to the position you want, go to the end of the motion tween and move rotate it again. Add a ‘Bounce’ ease for some extra spice.

Reverse the animation for more predictable results

My typical animation workflow is to create a composite of the key frames in an animation, and then add motion to each object as necessary. For anything that needs to slide in from outside the stage on the left, this means I need to move the object out on the first frame, reduce the alpha, go to the last frame, move it back to where I wanted and increase the alpha to 100%. This is how it has always been really, so I never bothered with it so much till one fine morning when I discovered "reverse keyframes". The idea is stupid simple really, but worth countless hours if you animate stuff in and out of the stage every day.

Here’s how it works. Once you have your composite in place, simply animate the opposite of the effect you need. Start from the final position of the object, and animate it going out towards the left. Include everything you need to make the animation perfect – alpha, blur, et al. Then, simply right-click the tween and click ‘reverse keyframes’, and voila! You have your slide in from left animation just as you need it to be.

Copy & paste in motion

Perhaps the biggest time saver for me since I started using the motion editor in Flash, has been ability to apply motion to an object, copy it and paste it for all other similar ones. This makes most sense when you have a bunch of objects moving in or out in a similar fashion – a bullet list, for example. Once you have applied a tween to one of the list items (assuming each one is a single movieclip on its own layer, of course), right-click the tween and select ‘Copy Motion’. Then simply select the first keyframes of all the other list items, right-click and select ‘Paste Motion’. You can then modify each one individually if necessary.


Miscelleneous Animation Tips

Here are some quick tips to save time, energy and a few frames when dealing with animation in Flash:

  • If you have a bunch of movieclips on a layer that you would like to animate individually, the first thing to do is to place them on separate layers. The next time you need to do this, select them all and press Shift+Ctrl+D. Flash will do the dirty work of placing them all on individual layers and will even name the layers to match each movieclip.
  • When making things appear on screen, set the Alpha value of the first frame to 5% instead of 0. This way you can see a faint version of the object to be able to select and manipulate it. Since it will anyways go from 5% to 100% in a matter of a few frames, the effect on the final animation is hardly even visible.
  • If you have elements appearing on screen, staying for a while and then disappearing, animate the appearance with a motion tween, then add a static keyframe on the next frame for the the duration than it will stay on screen. Copy the appearance motion, paste it at the end and reverse frames to have the element disappear the same way it appeared.

Conclusion

That brings us to the end of another chapter in the Flash Tips and Best Practices for Designers. If you used Flash a few years ago and have recently come back to it, you will no doubt appreciate the huge leap it has taken over the years as a professional grade animation tool. I hope these tips will help you grapple with some of the newer, surprisingly rarely documented tools and features. Have more tips and tricks to share? Let’s hear about them in the comments.



View full post on Activetuts+

Jan 19, 2011 Posted on Jan 19, 2011 in Hints and Tips | 0 comments

Animation in Silverlight

Silverlight has an animation system whereby most properties on user interface elements can be animated – properties like width, height, rotation, color and so on can all be targeted in a consistent way regardless of the type of the content itself. Let’s take a look at the basics of animations using Expression Blend.

The animation system is time based rather than frame based and so properties are animated from a value A to a value B over a specified time period with the option to control how the interpolation is done between the start and the end value. In this video, we’ll take a look at the basics of animations using Expression Blend in order to put together and control Storyboards made up of individual animations.


View Screencast

Don’t like ads? Download the HD 720 source, or subscribe to Activetuts+ screencasts via iTunes!


Useful Links

Mike Taulty Microsoft (UK): http://mtaulty.com: mtaulty@microsoft.com: twitter.com/mtaulty

  • An Introduction to Microsoft Silverlight 4
  • Visual Studio, Expression Blend (Getting Started)



View full post on Activetuts+

Jan 2, 2011 Posted on Jan 2, 2011 in Flash Video Training | 25 comments

How to make a stick man animation in flash (easy)


A tutorial how to make a jumping stick man fin flash CS3 professional

Dec 30, 2010 Posted on Dec 30, 2010 in Flash Video Training | 6 comments

Flash 8 Sprite Animation Tutorial


A short tutorial on animating sprites.

Page 1 of 1012345...10...»Last »
search search search search search
Find an Article
Categories
  • Flash Video Training
  • Hints and Tips
  • Recommended
Please Support Our Sponsors
Recent Posts
  • The Math and ActionScript of Curves: Drawing Quadratic and Cubic Curves
  • Weekend Lecture: Understanding Games, a Flash Game About Game Design
  • Weekend Lecture: Understanding Games, a Flash Game About Game Design
  • Workshop Coding Challenge: Fix This Breakout Game
  • Enable the Latest AIR SDK in Flash Professional CS5.5+
Tag Cloud
2011 ActionScript Active Activetuts+ Adobe animation Basic Basix Best Build Button Character Create Creating Critique Custom design Effect Effects Files Flash from Game Guide HTML5 Introduction Macromedia Motion Muzzle part Player Premium Professional Quick Silverlight Simple Text Tool Tutorial Tuts+ Tween Using Video website Workshop
About Our Site:

Hey there and welcome to "Flash Video Training Source", a resource for anybody interested in learning more about Adobe's great tool. We feature educational videos, which will help you master Adobe Flash and help you get to know all of its features. We at "Flash Video Training Source" believe that video training and video... more

Why don't you follow us on Twitter and get the latest video tutorials twitted to your account. Just click on the floating twitter bar to your right!

Go Back In Time
May 2012
M T W T F S S
« Apr    
 123456
78910111213
14151617181920
21222324252627
28293031  
Pretty Blank Box
top

Blogroll

  • Development Blog
  • Documentation
  • Plugins
  • Suggest Ideas
  • Support Forum
  • Themes
  • WordPress Planet

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org

Archives

  • May 2012
  • April 2012
  • March 2012
  • February 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
Powered by WordPress  |  Designed by Elegant Themes  |  Lightning Fast Hosting by Site 5 Hosting