Toxiclab.org

Tween animation using the AS3 and button

16.6.2009, 11:8
Submited in: Flash | Total Views: 16130

This, step by step, detailed action script lesson, will show you how to create tween animation using the AS3 and button. Using this lesson, you will also learn how to import any image into a flash stage, how to convert it into a Movie Clip Symbol, how to create instance name and much much more! Let's go!

Example:



Step 1

First, find any image which you like to use for this lesson.



Step 2


Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 32 and click ok.

Step 3

Call the current layer image. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 4

Choose now File > Import > Import to stage (Ctrl+R) and import any image into a flash stage.

Step 5

While the image is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.



Step 6

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip Image. See the picture below!



Step 7

Create a new layer above the layer image and name it tween button. After that, create some button, type on it tween and convert it into a button symbol.



Step 8

While the new made Button is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Button myButton. See the picture below!



Step 9

Create a new layer above the layer tween button and name it action.

Step 10

Select now the first frame of layer action and go to the Action Script Panel (F9). After that, enter this code inside the actions panel:

import fl.transitions.*;
import fl.transitions.easing.*;
 

myButton.addEventListener(MouseEvent.CLICK, tweenMyObject);


function tweenMyObject(event:MouseEvent) {
    var moveTween:Tween = new Tween(Image, "x", Elastic.easeOut, 0, 260, 3, true);
}

That's it!

Test your Movie (ctrl+Enter) and enjoy!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials


Resources Worth visiting


Friends