Making Tween Effect Using ActionScript 2.0

Get all answers regarding ActionScript 2.0

Making Tween Effect Using ActionScript 2.0

Postby Ashish on Thu Jan 21, 2010 10:24 am

Tween Effect Using ActionScript 2.0 on a Movie Clip or Button

Code: Select all
// Import tween classes
import mx.transitions.Tween;
import mx.transitions.easing.*;

// make a rectangle/button on stage, and give it instance name "rectangle_obj"

var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Elastic.easeOut, 0, 360, 3, true);


                        //Property use for the Tween class -------------------

var theDuration:Number = rotationTween.duration;
trace("Duration = "+theDuration);

var myFinish:Number = rotationTween.finish;
trace(myFinish);

rotationTween.FPS = 25;

var myFPS2:Number = rotationTween.FPS;
trace("rotationTween.FPS:" + myFPS2);

var myPosition:Number = rotationTween.position;
trace("myPosition " + rotationTween);


                        //Event handler use for the Tween class ---------------

rotationTween.onMotionFinished = function() {
    rotationTween.yoyo();
   
/*
More Methods for the Tween class -
   
Tween.yoyo()       | Instructs the tweened animation to continue from its current value to a new value.

Tween.fforward()    | Forwards the tweened animation directly to the end of the animation.

Tween.nextFrame()    | Forwards the tweened animation to the next frame.

Tween.prevFrame()   |  Directs the tweened animation to the frame previous to the current frame.

Tween.resume()      |  Resumes a tweened animation from its stopped point in the animation.

Tween.rewind()      |  Rewinds a tweened animation to the beginning of the tweened animation.

Tween.start()      |  Starts the tweened animation from the beginning.

Tween.stop()      |    Stops the tweened animation at its current position.

Tween.toString()   |  Returns the class name, "[Tween]".

Tween.yoyo()      |  Instructs the tweened animation to play in reverse from its last direction of tweened property increments.
*/
   
   
}

rotationTween.onMotionResumed = function() {
   trace("onMotionResumed Called...")
   // do your stuff here
}

rotationTween.onMotionStarted = function() {
    trace("onMotionStarted Called...")
   // do your stuff here
}

rotationTween.onMotionStopped = function() {
    trace("onMotionStopped Called...")
   // do your stuff here
}


   // press ctrl+enter to test the movie
   
   



More Easing Classes

var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Back.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Bounce.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Elastic.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Regular.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Strong.easeOut, 0, 360, 3, true);
var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", None.easeOut, 0, 360, 3, true);

More Easing Methods

var rotationTween:Tween = new Tween(rectangle_obj, "_rotation", Back.easeIn, 0, 360, 3, true);
easeOut
easeInOut
easeNone


You can apply the easing methods only to the following components:
Accordion, ComboBox, DataGrid, List, Menu, and Tree. Each component uses the easing methods to allow different customizations. For example, the Accordion, ComboBox, and Tree components let you select an easing class to use for their respective open and close animations. In contrast, the Menu component lets you define only the number of milliseconds that the animation lasts.

Bookmark and Share
Ashish
 
Posts: 153
Joined: Tue Oct 14, 2008 1:49 pm

Making Tween Effect Using ActionScript 3.0

Postby fffadmin on Wed Feb 03, 2010 8:04 pm

Making Tween Effect Using ActionScript 3.0

1. Make a movie Clip on stage of instance name "object"
2. Copy and paste this code on frame

Code: Select all
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;

var myTwn1:Tween=new Tween(object,"x",Strong.easeOut,start,end,time,true);
// Adding Events
myTwn1.addEventListener(TweenEvent.MOTION_STOP, myTweenStop);
function myTweenStop(event:TweenEvent):void {
   var myTwn2:Tween=new Tween(movieclip,"x",Back.easeOut,movieclip.x,300,1,true);
}


More Tween Event in As 3.0

MOTION_CHANGE
MOTION_FINISH
MOTION_LOOP
MOTION_RESUME
MOTION_START
MOTION_STOP

Get detail information form here -

http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/transitions/TweenEvent.html

Bookmark and Share
fffadmin
Site Admin
 
Posts: 127
Joined: Mon Sep 22, 2008 10:26 pm
Location: India

Re: Making Tween Effect Using ActionScript 2.0

Postby Ashish on Wed Jun 09, 2010 8:46 am

Hi

caurina tween classes are nice, See the attched sa files -

Code: Select all
import caurina.transitions.Tweener;

Tweener.addTween(clip_mc,{_x:400, time:0.5, transition:"easeOutBounce"});
Tweener.addTween(clip_mc,{_rotation:180, time:1, transition:"easeOutBounce"});
Tweener.addTween(clip_mc,{_xscale:5, time:0.5, transition:"easeOutBounce"});
Tweener.addTween(clip_mc,{_yscale:5, time:0.5, transition:"easeOutBounce"});



See more preview here (USE Firefox)
http://hosted.zeh.com.br/mctween/animationtypes.html

http://hosted.zeh.com.br/mctween/examples.html

http://hosted.zeh.com.br/mctween/

Bookmark and Share
Attachments
caurina.zip
Please login to download the attached source.
(56.34 KiB) Downloaded 145 times
Ashish
 
Posts: 153
Joined: Tue Oct 14, 2008 1:49 pm


Return to ActionScript 2.0

Who is online

Users browsing this forum: No registered users and 1 guest