Facebook Digg Technorati Delicious

Design SwanDesign Swan

RSS

AS3: Recursive Functions vs Loop Functions

In Flash 11,448 views

A recursive function is a function that calls itself. The following code shows a simple example of recursion.

function trouble(){
trouble();
}

A recursive function like above calls itself unconditionally, cause infinite recursion. To prevent this from happening, practical recursion functions call themselves only while a given condition is met.
Read the rest of this post »

AS 3: Functions as Values

In Flash 2,416 views

A function can be assigned to a variable, passed to a function, or returned from a function, just like any other values.

For example, the following code defines a function, a() and then assigns it to the variable b. Notice that the parentheses operator, (), is omitted; if it were included, the code would simply assign a()’s return value to b.

function a(){

}
var b=a;

Once a function has been assigned to a variable, it can be invoked through that variable using the standard parentheses operator, (). For example, the following code invokes the function a() through the variable b:

b();

Flash: the function of mergeAlpha in copyPixels

In Flash 6,315 views

the sytx of copyPixels is like this:
copyPixels(sourceBitmap:BitmapData, sourceRect:Rectangle, destPoint:Point, [alphaBitmap:BitmapData], [alphaPoint:Point], [mergeAlpha:Boolean]) : Void

Just assume, we have a destination BMP called desBMP, a sourceBitmap, and a alphaBitmap to provide secondary alpha setting.

desBMP.copyPixels(sourceBitmap,sourceRect,destpoint,alphaBitmap,alphaPoint,mergeAlpha);

1. Things need to be clarified first


For desBMP, its transparency attribute is only defined when this BMP is created. it won’t be changed when the copy pixel happens.

2. How mergeAlpha works?


I search tons of help documents. It just said like
“mergeAlpha:Boolean (default = false) — To use the alpha channel, set the value to true. To copy pixels with no alpha channel, set the value to false. ”
There is no exmaple showing how this works and the effect of it.

After hundreds of tests, I got the following conclusions:

Read the rest of this post »

18 flash loading animations

In Flash 92,290 views

Loading…. a most frequently used part in flash movie. To avoid your user see a blank screen and don’t know what happens, you provide them with loading animation indicating the progress and how long your user will be able to see the movie.

Of course, flash authorizing tool provide its progress bar component which has been universally used. However, if you want your movie looks different from the other, you might need to offer your user a unique loading animation. I have seen a lots of creative design for those. But, the more complicated loading animation, the larger swf file, which might cost user waiting sometime until they can see the loading part. That will be worse when our user has slow internet experience.

Read the rest of this post »