Monday, February 2, 2009

Image Reflection Class [FLASH 8/AS2.0]

As we know, AS2.0 has no bulit-in function to make the image reflection effect that users cannot make it from external loaded image dynamically. Therefore, I recently created a class to make it for ease.

Here is the client code used to make the shadow:

import flash.display.BitmapData;

// create the image
var bmd:BitmapData = BitmapData.loadBitmap("Cat");
var mc:MovieClip = this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
mc.attachBitmap(bmd, 0, "auto", true);
mc._x = (Stage.width - mc._width) / 2;
mc._y = 0;

// create the image reflection
var ir:MovieClip = attachMovie(ImageReflection.idName, "ir_mc", this.getNextHighestDepth());
ir.setBitmapData(bmd);
ir.place(mc, true);


Simple? The class wraps everything about the reflection effect. Here, the image reflection is also itself a movieclip so it can easily be altered its movieclip attritues.

The following attributes of the reflection can be changed:
- _yscale (default -100)
- _y (2px from the original image)
- _alpha (default 50)
- filters (default using the blur filter)



(80 alpha with no Blur effect)

Playback component [FLASH/AS2.0]



A playback controller basically has at least play and stop buttons. Sometimes we may have the pause, next and previous buttons to control more than one item such as images, videos or sounds.

This component can be used to handle the task for rapid development. It is for the rapid development because it has already handled all status control (for display). So we no need to write the gotoandplay scripts again and again. And this component is not a Compiled Flash Component(and i'm not recommended) so all we need to do is just to change the visuals if need.

The way I handle the event is by using AsBroadcaster for simplicity
(Even EventDispatcher can be used :)). The Playback is extended from MovieClip and with the following new events/properteis/methods:
Events (String):

- play
- stop
- pause
- next
- prev

Properties:
- status:String


Sample Code to handle the event:

playback_mc.addListener(this);
function changeStatus(status:String):Void {
trace(status);
}




(Pause during Playing)

Monday, October 20, 2008