Thursday, July 19, 2007

Beauty of Tweening with Tween & TransitionManager class

Yes!!! Its true that you can tween any object on the stage without actually applying tweening in the timeline & its amazing.

I am pasting a small code snippet below for a quick reference, which generates a bounce effect for a movie clip placed on the stage.

import mx.transitions.Tween;
import mx.transitions.easing.*;

new Tween(mcBall, "_y", Bounce.easeOut, 0, Stage.height-50, 3, true);


Parameters Explained:
1. "mcBall" is the movie clip placed on the stage
2. This parameter tells the constructor that what property will change in case of tweening. "_y" means the y position of the movie clip has to be changed.
3. The effect.
4. Starting y position.
5. End y position.
6. Duration of the tween.
7. Boolean Value related to the duration parameter, which indicates to use seconds if true, or frames if false.

The Tween and TransitionManager classes are available only in ActionScript 2.0, but these classes are available in both Flash Basic 8 and Flash Professional 8.

Wednesday, July 18, 2007

Actionscript/Javascript Communication

Now its much easier to communicate with Flash from Javascript and vice versa using ExternalInterface class.

You can create any function in Flash & then use the ExternalInterface class to register that function to call from the browser.

I am giving a step by step explanation to achieve the desired functionality.

First and foremost import the package using the statement given below -

import flash.external.*;

& then call the following function to register the function

ExternalInterface.addCallback("callASFunction", null, asFunction);

Explanation: The first parameter "callASFunction" is the name which will be used to call the function from the browser and the third parameter is the actual name of the function created in Flash. You can always keep the second parameter as null.