logo
468x60-2-495


  • Home
  • Privacy Policy
  • About
search
Mar 27, 2012 Posted on Mar 27, 2012 in Hints and Tips | 10 comments

Activetuts+ Workshop #3: Sci-Fi Particle Effects – Coding Challenge

For this Workshop, we’re doing a Coding Challenge! It can be tricky to sit down and practise new coding techniques, so here’s a fun exercise that’ll help you learn how to use particle effects by giving you some ideas for what to do with them. And if you share what you make with us, you could win a free three month subscription to Tuts+ Premium, too! Read on for details…


Background

Did you see Shiu’s recent Stage3D Starling Particle Effects tutorial? Here’s my favourite demo from it:

(Drag the mouse to move the ship, and press A to increase the smouldering.)

I think Starling and Stage3D are really important topics to learn for any Flash developer working on games or graphical effects. But I realise sometimes it can be hard to find inspiration for what to do with these tools, so this challenge is to encourage you to experiment and share your creations.


The Challenge

It’s simple: use the particle effect framework of your choice (in either Flash, Unity, or JavaScript) to create special effects inspired by sci-fi movies and TV programs.

Here are a few suggestions:

The time travel effects from Back to the Future:

Pretty much any Doctor Who intro:

Lightsabers:

Phasers (blasters, plasma rifles, etc.):

Star Trek transporters:

Hyperspace jump:

All these examples are in 3D, but yours doesn’t have to be – in fact, it’d probably make it easier to concentrate on the effects themselves if you used simple 2D graphics.

I recommend using Starling, if you’re using Flash. Unity has a particle system built in: Shuriken. JavaScript has a few options, too; you might like to try ThreeJS with or without SparksJS.


Let Us See!

This is a personal challenge; the aim is to help encourage you to play with new techniques, rather than to compete to win a prize. Having said that, I’d love to see what you make, and I’m sure other readers would find your examples really useful, too!

So, if you come up with something neat, please send it in using this form or link to it in a comment below. One random entrant will get a free three month Tuts+ Premium subscription!

I’ll update you with my own submission (and the code for it) at the end of next week.



View full post on Activetuts+

Mar 10, 2012 Posted on Mar 10, 2012 in Hints and Tips | 10 comments

Create Flash Screen Transition Effects Entirely With Code

Flash games are very much the bread and butter of indie pop-nerd culture. If you consider the slices of bread the menu and the game itself, what is left? The butter – the very substance that makes the bread taste that much more delicious. And in terms of a Flash game, what comes in between menus and games are the transitions!


Final Result Preview

This is an example pattern of the transition effect that we will be working towards:


Step 1: Setting Up

Per usual we need to create a new Flash File (ActionScript 3.0). Set its width to 400px, its height to 200px, and the frame rate to 30fps. The background color can be left as the default. Save the file; it can be named whatever you please. I named mine Transitions.fla.

Next we need to create a document class. Go to your Flash file’s properties and set its class to Transitions. Then create the document class:

package {
	import flash.display.*;
	import flash.events.*;

	public class Transitions extends MovieClip {
		static public var val:Number = new Number();
		static public var transitionAttached:Boolean = new Boolean();
		public function Transitions() {
			val = 0;
			transitionAttached = false;
		}
	}
}

The code just introduced two variables. The first will be used to select the effect’s pattern, and the second will be used to check against having multiple instances of the effect on the stage.


Step 2: Creating the Square Sprite

Our next step is to create the sprite that will be used as each square for the transition. Create a new class and save it as Square.as:

package{
	import flash.display.*;
	import flash.events.*;

	public class Square extends Sprite{
		public var squareShape:Shape = new Shape();
		public function Square(){

		}
	}
}

We use the squareShape variable to draw our shape inside the Sprite. Draw a rectangle 40px by 40px (Which is the full size) and set its scale to 0.1, a tenth of its size – this will aid us in the effect later:

addChild(squareShape);
squareShape.graphics.beginFill(0x000000,1);
squareShape.graphics.drawRect(-20,-20,40,40);
squareShape.graphics.endFill();
this.scaleX = 0.1;
this.scaleY = 0.1;

Step 3: Creating the Effect

Create another new class for the effect itself. Once we are finished, adding the effect to the stage will be very simple:

package{
	import flash.display.*;
	import flash.events.*;
	import flash.utils.*;

	public class FadeEffect extends Sprite{
		public var currentFadeOut:int = 00;
		public var currentSquares:int = 01;
		public var pauseTime:int = 01;
		public var tempNum:int = 00;
		public var fading:String = "in";
		public var fadeinTimer:Timer = new Timer(100);
		public var fadeoutTimer:Timer = new Timer(100);
		public var fadeArray:Array = [
                       //top
                       [[01,01,01,01,01,01,01,01,01,01],
                        [02,02,02,02,02,02,02,02,02,02],
                        [03,03,03,03,03,03,03,03,03,03],
                        [04,04,04,04,04,04,04,04,04,04],
                        [05,05,05,05,05,05,05,05,05,05]],
                       //bottom
                       [[05,05,05,05,05,05,05,05,05,05],
                        [04,04,04,04,04,04,04,04,04,04],
                        [03,03,03,03,03,03,03,03,03,03],
                        [02,02,02,02,02,02,02,02,02,02],
                        [01,01,01,01,01,01,01,01,01,01]]];
		public var squaresArray:Array = new Array();
		public function FadeEffect(){

		}
	}
}

You are probably thinking “that is a heck of a lot of variables, what all are they used for?”:

  • currentFadeOut - used as a check for tempNum to see how many squares are to be scaled
  • currentSquares - the current value indicating which squares should be attached and/or scaled
  • pauseTime - a simple integer to give a slight pause in between transitions and removing itself
  • tempNum - used to check what numbers in the array are to be scaled
  • fading - a string to check if the transition is fading in or out
  • fadeinTimer - a timer that is called to begin the fading in of the current value of currentSquares
  • fadeoutTimer - another timer that is called to begin the fading out of the current value of currentSquares
  • fadeArray - the 3D array that contains all the transition patterns
  • squaresArray - an array for the Square sprites

Our effect will begin by initiating an event listener for fadeInTimer and starting it. We also need to add an event listener to continuously scale all of the sprites to their correct sizes. Use the following code inside the constructor:

fadeinTimer.addEventListener("timer", fadeSquaresInTimer);
fadeinTimer.start();
addEventListener(Event.ENTER_FRAME, enterFrame);

The next step is to create those two event listeners. We will start with the easier of the two, the enterFrame function:

public function enterFrame(e:Event){
	for each(var s1 in squaresArray){
		tempNum+=1;
		if(fading=="in"){
			if(s1.scaleX<=1){
				s1.scaleX+=0.05;
				s1.scaleY+=0.05;
			}
		}else if(fading=="out"){
			if(tempNum<=currentFadeOut){
				if(s1.scaleX>=0.1){
				s1.scaleX-=0.05;
				s1.scaleY-=0.05;
				}else{
					if(s1.visible == true){
						s1.visible = false;
					}
				}
			}
		}
	}
	tempNum=00;
}

It may not make total sense right now, but this should help shed some light.

  • s1 is the instance name that will be given to the Squares when we create them in a later function.
  • They are added to an array called squaresArray to keep track of the number of them and we perform the same operation for every object in the array.
  • Next we increase tempNum (used in the fading out if-statement) which is used to scale the sqaures in the order that they were added to the array. This means it is not pattern dependant and will work with any pattern.

After that…

  • We check if fading is true or not.
  • If true, it scales all the squares up until they reach their full size (they begin scaling immediately after currentSquares increases).
  • Once it begins fading out things become a little trickier; we only scale down the squares that are lower than the current value of currentFadeOut (these are the ones that should be scaling, all others should remain at full scale until the value increases).
  • Once they have scaled down to a tenth of the size we make those squares invisible (they will be deleted with the whole effect).

It’s time to add the event listener for the timer:

public function fadeSquaresInTimer(e:Event){
	fadeSquaresIn(fadeArray[Transitions.val]);
	currentSquares+=1;
}

At first glance it looks less complicated, but you should notice that we are calling a function with the fadeArray as the parameter. Which pattern is selected from the array depends on what you set val equal to in the Transitions class; right now it should use the first pattern because val is set to 0.

The next step is to create the fadeSquaresIn function that is called from the previous timer:

public function fadeSquaresIn(s:Array){
	for (var row=0; row<s[0].length; row++) {
		for (var col=0; col<s.length; col++) {

		}
	}
}

First thing that we accomplish is iterating through the selected pattern. We start at row 1, colomn 1 and cycle through every colomn until the end of the row has been reached. Then we move onto the next row and repeat the process.

The next thing to do is compare the current item in the array to the value of currentSquares:

if(int(s[col][row]) == currentSquares){

}

If they are equivalent we add a square, position it accordingly, and push it onto the squaresArray so that it can be scaled:

var s1:Sprite = new Square();
s1.x = 20+(row*40);
s1.y = 20+(col*40);
addChild(s1);
squaresArray.push(s1);

We are almost done with this function, we just have to perform a check for when there are the same number of squares as there are items in the pattern. We do so by adding the following if-statement outside both for-loops:

if(squaresArray.length == (s[0].length * s.length)){
	fadeinTimer.stop();
	addEventListener(Event.ENTER_FRAME, pauseBetween);
}

Self explanatory – we stopped the timer and called an event listener for the pause between fading in and fading out. That function is used to initiate the fading out and may also be used to cause change in your game:

public function pauseBetween(e:Event){
	pauseTime+=1;
	if(pauseTime==60){
		currentSquares=01;
		fading="out";
		fadeoutTimer.addEventListener("timer", fadeSquaresOutTimer);
		fadeoutTimer.start();
		removeEventListener(Event.ENTER_FRAME, pauseBetween);
	}
}

We won’t spend much time on this function due to its simplicity. Here we increase the value of pauseTime, and once it equals 60 (meaning two seconds have passed) we set the value of currentSquares back to 1, set fading to "out" so that the squares can scale backwards, remove the listener for pauseBetween() itself, and add an event listener for this new function:

public function fadeSquaresOutTimer(e:Event){
	fadeSquaresOut(fadeArray[Transitions.val]);
	currentSquares+=1;
}

This works much like fadeSquaresInTimer(), though this time we are calling the function fadeSquaresOut():

public function fadeSquaresOut(s:Array){
	for (var row=0; row<s[0].length; row++) {
		for (var col=0; col<s.length; col++) {
			if(int(s[col][row]) == currentSquares){
				currentFadeOut+=1;
			}
		}
	}
}

We cycle through, but this time when we find an equivalent item we increase the value of currentFadeOut so that the next item in the squaresArray can begin fading out.

Almost finished now; all that’s left is to stop the timer and remove the effect. Add this if-statement outside of the two for-loops:

if(currentFadeOut == (s[0].length * s.length)){
	fadeoutTimer.stop();
	pauseTime=01;
	addEventListener(Event.ENTER_FRAME, delayedRemove);
}

This checks whether all of the items have begun fading out. If so, it then stops the timer, sets pauseTime back to 1 and adds an event listener for the function delayedRemove():

public function delayedRemove(e:Event){
	pauseTime+=1;
	if(pauseTime==30){
		Transitions.transitionAttached = false;
		removeEventListener(Event.ENTER_FRAME, delayedRemove);
		stage.removeChild(this);
	}
}

Like before we increase the value of pauseTime, and once it equals 30 (1 second) we set the boolean back to false so that the effect can be added once again. We remove this event listener and we remove this effect from the stage.


Step 4: Adding the Effect

Now comes the easy part. Add the following code inside the document class constructor to add the effect:

if(transitionAttached == false){
	transitionAttached = true;
	var f1:Sprite=new FadeEffect;
	stage.addChild(f1);
}

Step 5: Creating More Patterns

Feel free to create your own patterns! It’s extremely simple, just create a new 2D array inside the 3D array. Here is the array that I have created (just replace your 3D array with it). It includes 8 different transitions:

[//top
[[01,01,01,01,01,01,01,01,01,01],
[02,02,02,02,02,02,02,02,02,02],
[03,03,03,03,03,03,03,03,03,03],
[04,04,04,04,04,04,04,04,04,04],
[05,05,05,05,05,05,05,05,05,05]],
//bottom
[[05,05,05,05,05,05,05,05,05,05],
[04,04,04,04,04,04,04,04,04,04],
[03,03,03,03,03,03,03,03,03,03],
[02,02,02,02,02,02,02,02,02,02],
[01,01,01,01,01,01,01,01,01,01]],
//left
[[01,02,03,04,05,06,07,08,09,10],
[01,02,03,04,05,06,07,08,09,10],
[01,02,03,04,05,06,07,08,09,10],
[01,02,03,04,05,06,07,08,09,10],
[01,02,03,04,05,06,07,08,09,10]],
//right
[[10,09,08,07,06,05,04,03,02,01],
[10,09,08,07,06,05,04,03,02,01],
[10,09,08,07,06,05,04,03,02,01],
[10,09,08,07,06,05,04,03,02,01],
[10,09,08,07,06,05,04,03,02,01]],
//top-left
[[01,02,03,04,05,06,07,08,09,10],
[02,03,04,05,06,07,08,09,10,11],
[03,04,05,06,07,08,09,10,11,12],
[04,05,06,07,08,09,10,11,12,13],
[05,06,07,08,09,10,11,12,13,14]],
//top-right
[[10,09,08,07,06,05,04,03,02,01],
[11,10,09,08,07,06,05,04,03,02],
[12,11,10,09,08,07,06,05,04,03],
[13,12,11,10,09,08,07,06,05,04],
[14,13,12,11,10,09,08,07,06,05]],
//bottom-left
[[05,06,07,08,09,10,11,12,13,14],
[04,05,06,07,08,09,10,11,12,13],
[03,04,05,06,07,08,09,10,11,12],
[02,03,04,05,06,07,08,09,10,11],
[01,02,03,04,05,06,07,08,09,10]],
//bottom-right
[[14,13,12,11,10,09,08,07,06,05],
[13,12,11,10,09,08,07,06,05,04],
[12,11,10,09,08,07,06,05,04,03],
[11,10,09,08,07,06,05,03,03,02],
[10,09,08,07,06,05,04,03,02,01]]];

You can change the value of Transitions.val to choose another pattern – for example, if val is 3, the transition will sweep in from the right.


Conclusion

Thanks for taking the time to read this tutorial. If you have any questions please leave a comment below. And if you would like a challenge, try making the effect fade in with one pattern and fade out with an opposing one.



View full post on Activetuts+

Apr 1, 2011 Posted on Apr 1, 2011 in Hints and Tips | 2 comments

Exclusive Freebie: Ten Fab Filter Effects for Your Flash Textfields

If you enjoyed Muhammed Abid’s tutorial on glassifying your text with Flash filters, you’ll love this Exclusive Freebie from frequent author Carlos Yanez. It’s a set of ten such effects, ranging from gold to bubble gum, which you can easily copy and paste to apply to any text in any of your Flash projects.


The Final Results

Here’s what the ten different effects look like in action:




How To Use These Effects

Download the source zip file, extract it to your hard drive, and open TextFXPack.fla. You’ll see all of the effects available on the first frame of the timeline.

Click on the text (not the background) of the effect you wish to duplicate:

Free Flash text filter effects

In the Properties panel, check out the Filter section:

Free Flash text filter effects

Click the little clipboard icon, and press “Copy All”:

Free Flash text filter effects

In your own Flash project (i.e., another FLA), select the text to which you’d like to apply the filter:

Free Flash text filter effects

In the Filters section of the Properties panel, click the little clipboard again and select “Paste”:

Free Flash text filter effects

Tada!

Free Flash text filter effects



View full post on Activetuts+

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

Custom Muzzle Flashes (After Effects Tutorial) PART 1


This tutorial is packed with many useful tips. Everything from Keying, adding backgrounds, color correction, muzzle flash creation, motion tracking, camera movement, adding bullet shells plus much more. Thanks for your great comments so far and your suggestions. Marko Los Delirium VFX

Jan 3, 2011 Posted on Jan 3, 2011 in Flash Video Training | 17 comments

Custom Muzzle Flashes (After Effects Tutorial) PART 2


This tutorial is packed with many useful tips. Everything from Keying, adding backgrounds, color correction, muzzle flash creation, motion tracking, camera movement, adding bullet shells plus much more. Thanks for your great comments so far and your suggestions. Marko Los Delirium VFX

Page 1 of 41234»
search search search search search
Find an Article
Categories
  • Flash Video Training
  • Hints and Tips
  • Recommended
Please Support Our Sponsors
Recent Posts
  • Tuts+ Community Meetup in New York!
  • HTML5 Canvas Optimization: A Practical Example
  • Recreate the Cover Flow Effect Using Flash and AS3
  • Drawing Activetuts+ to a Close
  • Intro to Dart: Creating a Marquee
Tag Cloud
2011 ActionScript Active Activetuts+ Adobe animation Basic Basix Best Build Button Character Code 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+ 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 2013
M T W T F S S
« Jul    
 12345
6789101112
13141516171819
20212223242526
2728293031  
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

  • July 2012
  • June 2012
  • 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