as3

3 ways to reduce redundant code in your adobe flash actionscript 3 projects

Posted in as3 on November 24th, 2009 by admin – Be the first to comment

There is 3 great ways to reduce redundant code in your actionscript 3 projects:

1) Aggregation

If objects A and B has same function, why not put that function on a separate object C and let both other objects call it from there.

2) Composition ie. inheritance

Put your redundant code to a class C and let your objects A and B inherit those methods from there.

3) Last but not least: include -statement

Sometimes good old include -statement is best way to go. Just put your code on separate file and include it where ever it’s needed. Quick, dirty and powerfull! :)

Included code doesn’t even have to be full class or  function, but any usefull bit of code will do.

Clearer adobe actionscript AS3 code by using objects as function parameters

Posted in as3 on November 22nd, 2009 by admin – Be the first to comment

Classical implementation of a Adobe flash actionscript function could be something like this:

function doSquareThing(x,y,width,height,fillcolor,bordercolor,callback){
      //Do something with the parameters
}

doSquareThing(10,20,15,15,#cccccc,#000000,squareReady);

Everytime you call the function you have to remember what order the parameters should be. If somebody else is reading the code he/she can’t know what the parameters are without seeing documentation or function definition.

Better way to do the same thing is read more »

Adobe flash actionscript as3 mask movieclips with gradient alpha masks

Posted in as3 on November 22nd, 2009 by admin – Be the first to comment

With actionscript as3  you can ad a mask to a display object ie. movieclip with simple line of code.

mc_to_be_masked.mask = masking_mc;

But this will usually ignore any alpha gradients you might have in your masking movie clip.

To make the masking work  properly, you have to read more »

Flash textfields styling with CSS line-height

Posted in as3 on November 22nd, 2009 by admin – Be the first to comment

Flash textfields doesn’t support css line-height property. But they do support property “leading”. Default value for leading is 0.

So for smaller line-height between lines of textfield you have to set leading on a css -style to negative values and vice versa for bigger line-height.

Something like this for decreased line-height:

.mystyle{
leading:-2px;
}

Globals in flash as3

Posted in as3 on September 15th, 2009 by admin – Be the first to comment

Actionscript 3 doesn’t have build-in global variables. Globals are however easy to implement with just one small class with a public static object. Just three easy steps. read more »

AS3 main class – interaction between methods and timeline (for beginners)

Posted in as3 on September 14th, 2009 by admin – Be the first to comment

After you have setup main class for your flash project, and perhaps put it in to a package, you can start writing code for your application.

Calling timeline from main class

read more »

Using packages in flash AS3 (for beginners)

Posted in as3 on September 13th, 2009 by admin – Be the first to comment

Many people, when starting with flash actionscript 3 developement, first save all the class files to the same folder as the main Flash file (.fla). It works allright when applications are small and you don’t have to share them with anybody.

However, there is a better way to organise your code, that’s called packages ( That’s a fancy object oriented  name for subfolders) read more »

Adobe AS 3 start (for beginners)

Posted in as3 on September 13th, 2009 by admin – Be the first to comment

new_actionscript_fileAdobe Actionscript 3 based flash project (with flash IDE) has a bit different file structure, than traditional Adobe flash project. Every as3 flash application has a main class where the hole application starts. read more »