logo
468x60-2-495


  • Home
  • Privacy Policy
  • About
search
May 21, 2012
The Math and ActionScript of...
We see lines used in a lot of scenarios; curves are also used but perhaps not as frequently – but that doesn’t undermine their importance! In this tutorial we shall take a closer look at...
read more
May 20, 2012
Weekend Lecture: Understandi...
Interested in game design? This weekend, we feature a set of four interactive lectures: games that are about game design, by Pixelate. Play the Games Bub and Bob, two little 8-bit guys, will talk...
read more
top
Dec 25, 2010 Posted on Dec 25, 2010 in Hints and Tips | 0 comments

Quick Tip: Create a Minimalistic SandClock Using ActionScript 3

Read through the easy steps in this Quick Tip to create a Minimalistic SandClock with ActionScript.


Final Result Preview

Let’s take a look at the final result we will be working towards:


Step 1: Brief Overview

Using Arrays and a premade square MovieClip we will create a SandClock that will be animated by a Timer.


Step 2: Set Up Your Flash File

Launch Flash and create a new Flash Document, set the stage size to 400x250px and the frame rate to 24fps.


Step 3: Interface

This is the interface we’ll be using, the squares in the image are actually one single blue square MovieClip exported for use with ActionScript, with a linkage name of Square. A simple button named startButton will be used to build and start the clock.


Step 4: ActionScript

Create a new ActionScript Class (Cmd+N), save the file as Main.as and write the following lines. Read through the comments in the code in order to fully understand the class behavior.

package
{
	import flash.display.Sprite;
	import flash.utils.Timer;
	import flash.events.TimerEvent;
	import flash.events.MouseEvent;

	public class Main extends Sprite
	{
		private var clockArray:Array = [15,13,11,9,7,3,1];//Stores the number of squares per line
		private var top:Array = []; //will hold the squares on the top part of the sandclock
		private var container:Sprite = new Sprite(); //stores all the movieclips
		private var containerCopy:Sprite = new Sprite(); //will duplicate the top part to make the bottom
		private var timer:Timer = new Timer(1000); //a timer executed every second
		private var counter:int = 0; //will count the seconds, used to stop the timer

		public function Main():void
		{
			startButton.addEventListener(MouseEvent.MOUSE_UP, buildClock);//a listener in the start button
		}

		private function buildClock(e:MouseEvent):void
		{
			startButton.removeEventListener(MouseEvent.MOUSE_UP, buildClock); //disables the button
			startButton.enabled = false;

			var clockLength:int = clockArray.length;

			/* this double for browses through the clock array length AND the value of each array element
				creating 7 lines (length) of squares with 15, 13, 11(element value) and so on  */

			for (var i:int = 0; i < clockLength; i++)
			{
				for (var j:int = 0; j < clockArray[i]; j++)
				{
					var s:Square = new Square();
					var sc:Square = new Square();

					s.x = 70.5 + (s.width * j) + (1 * j) + (i * (s.width + 1));
					s.y = 84.5 + (s.height + 1) * i;
					sc.x = s.x;
					sc.y = s.y;

					if (i >= 5)
					{
						s.x = 70.5 + (s.width * j) + (1 * j) + (i * ((s.width) + 1)) + (s.width * 2 - 4);
						sc.x = s.x;
					}

					container.addChild(s);
					containerCopy.addChild(sc); //creates a copy for the bottom part

					top.push(s);
					sc.alpha = 0.2; //makes the bottom part semi transparent
				}

				addChild(container);

				containerCopy.x = 225; //positions and rotates the bottom part
				containerCopy.y = 247;
				containerCopy.rotation = 180;

				addChild(containerCopy);
			}

			timer.addEventListener(TimerEvent.TIMER, startClock); //start the timer
			timer.start();
		}

		/* this function executes every second, it changes the alpha of the corresponding square to make the sand effect.
			when the time is done stops the timer and calls a function */

		private function startClock(e:TimerEvent):void
		{
			container.getChildAt(counter).alpha = 0.2;
			containerCopy.getChildAt(counter).alpha = 1;
			counter++;

			//60 seconds

			if (counter >= 59)
			{
				timer.stop();
				timer.removeEventListener(TimerEvent.TIMER, startClock);
				timeComplete();
			}
		}

		private function timeComplete():void
		{
			//do something here
		}
	}
}

You can adjust the Timer and the counter value to make the sandclock duration greater or shorter.


Step 5: Document Class

Remember to add the class name to the Class field in the Publish section of the Properties panel.


Conclusion

Why not use this SandClock to give your application or game a nice touch?

I hope you liked this tutorial, thank you for reading!



View full post on Activetuts+

Dec 25, 2010 Posted on Dec 25, 2010 in Flash Video Training | 25 comments

Xbox 360 Flash Tutorials Video 5: Flashing BenQ With 1.6


Here is how to flash a xbox 360 benq with the latest firmware for iXtreme 1.6 Using Jungleflasher. Please comment and rate. Subscribe for future videos. Xbins Download: www.megaupload.com !OR! Visit www.hottwings.tk Part 1 Downloads – All On My Website Part 2: Unlock The Drive – Required For Flashing Modding Part 3: Reading Firmware Part 4: Writing Firmware (Flash)

Dec 25, 2010 Posted on Dec 25, 2010 in Flash Video Training | 3 comments

Animating Classic Cartoon Eyes in Flash pt. 2


tonyteach.com Here is a basic Flash tutorial to animate cartoon eyes wa blink (pt.2). This tutorial uses Graphic symbols set to Single Frame. Im using CS4, but this technique is doable in earlier versions of Flash as well, (even before any CS version).

Dec 24, 2010 Posted on Dec 24, 2010 in Flash Video Training | 25 comments

Create Flash Button


www.websiteguruservices.com How To Create Flash Navigation Buttons In Flash MX.

Dec 24, 2010 Posted on Dec 24, 2010 in Flash Video Training | 22 comments

Flash Pen Tool


Flash tutorial on using the pen tool

Page 89 of 253« First«...102030...8788899091...100110120...»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