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.

Monday, June 18, 2007

Mobile Apps with Flash Lite

Hi Peeps,

I just tried playing around with Flash Lite & found it really cool to generate mobile apps & you can test your application in the emulator while developing it.

I created a very small application & found it really interesting and easy. I used Flat Lite 1.1 with Flash 8.0 to generate this application.

I had an image & a button placed in the first screen & clicking on that button made the image run out of the screen with motion tween.

It was fun & easy.

Thursday, June 7, 2007

Customizing Flash Context Menu

Flash context menu is the menu you see when you right click on any of the running Flash animations or applications.

I have customized it many times before but one of my friend asked me few days back that if he can remove the options from the Flash shortcut(context) menu so I thought of posting it on my blog for all of those trying to customize it.

I am pasting the code along with the explanation below -

var cMenu = new ContextMenu();

function dummy() {
trace("option clicked");
var cMenuItem1 = new ContextMenuItem("Option 1", dummy);
var cMenuItem2 = new ContextMenuItem("Option 2", dummy);
var cMenuItem3 = new ContextMenuItem("Option 3", dummy);
cMenu.customItems.push(cMenuItem1,cMenuItem2,cMenuItem3); = cMenu;

The ContextMenu class provides runtime control over the items in the Flash Player context menu, which appears when a user right-clicks on Flash Player.

First of all I have created an object of the class ContextMenu called "cMenu" & then called the built in function hideBuiltInItems() using the object which will hide the default options appearing on the right click.

The function dummy has been created to display a message in the output panel whenever user will click on the customized options added in the menu.

ContextMenuItem class is used to create objects for creating customized items, so for each option you want to put in the menu, you have to create an object. While creating object it takes two parameters, the caption & the function which will be executed on the click.

After doing this you have to push the items in the menu and to do that you use in built array associated with ContextMenu called ContextMenuItems.


So using the above code you push the items created into the menu & then your menu is ready to go after you change the current menu by putting in your menu name in the "menu" property using the following statement - = cMenu;

Enjoy Customizing Context Menu...

Thursday, May 24, 2007

XML Preloader

Hey Guys,

Now you can show a preloader animation even while loading any data from a XML file. The code for the preloader is like any other preloader in Flash except there is a change while extracting the loaded and total bytes -


myXML here refers to your XML object created to load the XML file.

Please feel free contact me at in case of any query.

Cheers :)

Friday, April 27, 2007

Loading Image Dynamically

I don't recommend to use LoadMovie for loading images dynamically because you can not actually trace the progress & perform the next action depending upon the progress.

I will suggest using MovieClipLoader class and its function loadClip using which you can actually trace the progress & if required can play preloader animation & then hide it when the loading of image is completed.

Please feel free to post your query if you have any.

Thursday, April 26, 2007

Parsing XML in Flash

XML2Object is an extension for Macromedia Flash & just to let those people know who are creating dynamic website or applications by integrating & reading data from XML that it makes your life very easy by creating an object of complete XML.

After creating an object of XML2Object you can extract data by using the following format -

It is very easy & faster to use rather than parsing through each node of XML file & then extracting the data.