Browse > Home / Archive by category 'ActionScript'

| Subcribe via RSS

The ‘new’ Class keyword and creating dynamic buttons in AS3

January 6th, 2010 | No Comments | Posted in ActionScript, Tutorials

I use dynamic movieclips in almost every project I work on and AS3′s new method of adding dynamic movieclips to the stage makes it easy, instead of using AS2′s duplicateMovieClip() method. I will show you some tips and tricks to easily create applications in which dynamic movieclips are used and easily manage those movieclips.

1. Create a movieclip with a linked Class
First create a new AS3 project in Flash and create a new movieclip (Insert > New Symbol…), let’s call it MenuButton. In the Linkage properties (click the Advanced button if needed), check the Export for ActionScript box and for this example just leave all the settings like they are so click OK. You can put anything inside the movieclip you want but for this example I’m putting in a black box with the following properties: X:0, Y:0, width:100, height:20. Now return to the root scene, highlight the empty keyframe and open the actions tab.

More »

Mouse Proximity Blur Tutorial

March 31st, 2009 | 5 Comments | Posted in ActionScript, Tutorials

How to make a menu or icons with a proximity blur effect

A mouse proximity blur is an effect which means the amount of blur on the movie clip is dependent on the distance between the movie clip and the mouse cursor.

In this tutorial, I will take you through a very basic and easy tutorial on how to set up a simple iconic menu and walk you through the ActionScript (AS3) to add this effect on the menu. I first created the mouse proximity blur menu as an experiment in my last post here. This is what the finished product will look like:

More »

Introduction to OOP

January 27th, 2009 | No Comments | Posted in ActionScript, Tutorials

OOP: Object Oriented Programming

Object Oriented Programming is a concept rather than a technique or method of coding.  However, within the concept of OOP, there are certain techniques and methods.  Object Oriented Programming (OOP) is an object-based style of programming that uses objects to store and work with data. Templates known as classes are used to define the properties and methods that make up objects in code.  So the point of it is to easily re-use robust code, making developing applications much easier, stronger, and allows more possibilities.

In this tutorial, I will take you through a very basic and easy, but very powerful method and aspect of OOP in Flash.  We will create a loading circle that spins around by attaching external code to the movie clip.  This will hopefully demonstrate to you the power of OOP.

More »

Flash Tip: Casting

October 17th, 2008 | 5 Comments | Posted in ActionScript

Casting can be very useful and in some cases, necessary. AS3 has a system of strict datatyping, much like AS2, but now even more strict. Using casting, you can transform one datatype into another, so to speak. For example, if you are receiving a string in Flash, say “item07″ and you need to use the number from that string, you can extract that using String methods and then cast the string into a uint datatype or Number datatype. Here is a working example of why you would do this, in AS3 code:

var str:String = "item07";
str = str.substr(4);
str += 3;
trace(str); // this will give the result of str being 073

var str:String = "item07";
str = str.substr(4);
var res:uint = uint(str) + 3;
trace(res); // this will give the result of res being 10


The uint(str) is where casting is used. The way you cast a datatype is you wrap it in a different datatype. For example, you can use MovieClip(value), Number(value), String(value), etc. Also, sometimes in situations, I have to use casting to refer to a movie clip in the parent clip, …MovieClip(parent).myMovieClip…
I hope you found this useful, thanks.

5 Flash Tips

September 14th, 2008 | 1 Comment | Posted in ActionScript


FPS

It is good to have a FPS (frames per second) value that is not too slow, but not too fast. The default value is 12, which is too slow. It’s too slow, because when you create animations on the timeline, it will look slow and blocky. I know many expert flashers keep it at 24 fps, which is a good speed. It is fast enough so that the animations will look smooth, but slow enough so that the user’s computer won’t lag. For example, if there are a ton of animations playing at once, the flash player might lag because it takes a lot of CPU to play. Further more if the animations are frame based and the fps value is jacked up to something like 40 or 50, it will lag a lot more. However, the great people over at Adobe are constantly working at performance, among other things, and are setting impressive milestones of increasing Flash’s performance and CPU usage. There was a major bump in performance from Flash 8 and AS2 to Flash CS3 and AS3. When using AS3, the Flash Player uses a entire new virtual engine to process the file and code, which is much better than the old versions and engine because it is much more strict and streamlined. But I always keep my FPS value at 30. As long as you keep the processing usage in mind, I advise just finding a value that you are comfortable with.

More »

The Tweener Class

August 30th, 2008 | 1 Comment | Posted in ActionScript


Introduction

Simple enough, Tweener is a class for creating tweens in Flash.  Tweener surpasses and replaces, at least for me, the standard Flash Tween class.  I have this opinion not only because I just like it and its easy to use, but for two main reasons: frame animation and garbage collection, which I will go into more detail later on.


How do I get Tweener and how do I use it?

More »

Migration from AS2 to AS3

July 14th, 2008 | 3 Comments | Posted in ActionScript

I just wanted to make a note on the migration from AS2 to the new AS3. There were some significant changes and I’ve heard many people are still struggling to switch to AS3.  When I was switching to AS3, I found that I just needed a starting point, some tips to start me off and then I quickly picked it up and I actually find myself thinking that its not that different from AS2.  I’m going to just post a few code snippets, one from AS2 and then the AS3 form of the same functionality.  Hopefully my choices prove to be as commonly used as I use them – I will try to post some of the code snippets that I needed to start me off. But if you are reading this and would like to know the AS3 version of a little code that you commonly use, please post a comment and it could spark a discussion about this issue related to whatever you are having trouble with.

More »

9-slice scaling (scale9Grid)

July 8th, 2008 | No Comments | Posted in ActionScript

What is 9-slice scaling?

9-slice scaling was introduced in Flash 8.  It is called 9-slice scaling when you open the property window of a library movie clip (the advanced tab has to be open to see it).  This property can also be set in ActionScript and in code, it is called scale9Grid.  Enabling this property will split the movie clip into 9 parts: 1 center piece, 4 sides, and 4 corners.  When the movie clip is resized, it will keep the outer edge in tact, while the main part gets resized.  It does this by resizing the center piece in both width and height, resizing the top and bottom sides in width, resizing the left and right sides in height, and the corners will not be resized at all.  What is this used for?  This solves the problem of resizing movie clip boxes that have rounded corners.  Every developer that used Flash MX or earlier versions of Flash knows that dynamically resizing a movie clip box with rounded corner was a huge hassle.  This was a fantastic new feature, but unfortunately, frustrated developers more than it pleased them – it has many bugs.

More »