VIDEO: The YoYo Method and Motion Tween Events

Mon, Nov 9, 2009

ActionScript

VIDEO: The YoYo Method and Motion Tween Events

This movie requires Flash Player 9

This tutorial we demonstrate how to add event listeners to Motion Tweens and we also show how the YoYo motion tween method works.

CLICK HERE FOR THE FIRST PART OF THIS TUTORIAL
DOWNLOAD THE SOURCE FILE:
Yoyo2

SEE THE ADOBE METHOD REFERENCE

CLICK HERE FOR A COMPLETE ACTIONSCRIPT 3.0 CARTOON SMART TUTORIAL

HERE IS THE SOURCE CODE!

//The ActionScript 3.0 The YoYo method and Tween Events
// Avraham Saltoun
// solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE

// Let’s start by importing libraries
import fl.transitions.Tween;
import fl.transitions.easing.*;
// This will import all eases

//Motion Tween events is a library that
//has to be imported
import fl.transitions.TweenEvent;
// Now we can start coding

var xTween : Tween;
// This is the variable that will hold the Tween
// in our case the “Tween” is the horizontal motion
// on stage

// This starts the animation on load
xTween = new Tween(boat_mc,”x”,None.easeNone, 10,450,7,true);

// boat_mc is the name of the symbol instance
// x is the tween type, this means horizontal movement
// none is the bounce and ease
// starts at coordinate 10 – that is the left side of the stage
//and finishes at 450, taking all together 7 seconds.
// the true states that we are counting seconds, not milliseconds…

// we have currently 3 buttons on stage
//Event Listeners – this will set the compiler
// waiting for button clicks
play_btn.addEventListener(MouseEvent.CLICK, playTween);
stop_btn.addEventListener(MouseEvent.CLICK, stopTween);
rewind_btn.addEventListener(MouseEvent.CLICK, rewindTween);

// Let’s add an event listener to the TWEEN!
xTween.addEventListener(TweenEvent.MOTION_FINISH, motionFinish);
//When the tween is finished will fire the motionFinish function

//Functions
//Play
function playTween (event:MouseEvent):void
{xTween.resume();}

//Stop
function stopTween (event:MouseEvent):void
{xTween.stop();}

//Rewind
function rewindTween (event:MouseEvent):void
{xTween.rewind();}

// This will stop the animation
// on the very beginning after it started
xTween.stop();

function motionFinish(event:TweenEvent):void
{

xTween.yoyo();
//The yoyo method will play back and foward

}

// Subscribe from the website
// Thanks for watching
// see you next tutorial

Related Articles:

, , , , , , , , , , , , , , , , ,

2 Responses to “VIDEO: The YoYo Method and Motion Tween Events”


Trackbacks/Pingbacks

Leave a Reply

You must be logged in to post a comment.

My name is Avraham Saltoun, and I live in Jerusalem, Middle East. I am currently on my mid  40's and I am a computer programming technician. Here you will find over one hundred quality video tutorials on Actionscript, and yes, I give online support for aspiring programmers, and pros as well, sharing screen on skype and delivering source code by email, click the button for live flash actionscript support now!

 
oDesk Certified Action Script Programmer
oDesk Certified Adobe Flash CS3 Designer
oDesk Certified Adobe Photoshop 6.0 Designer
Skype Me™!

$7.49 .Com! Score Savings Cartoon Smart Tutorials


1,260
Unique Visitors
Previous 30 Days
Powered By Google Analytics