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!
// 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




February 7th, 2012 at 6:22 am
I am not sure the place you are getting your information, but great topic. I needs to spend some time finding out more or figuring out more. Thanks for wonderful info I was searching for this information for my mission.
February 7th, 2012 at 7:44 am
Exalted website you have here. Respect
February 7th, 2012 at 10:23 am
Yeah !… life is like riding a bicycle. You will not fall unless you stop pedaling!!…
February 7th, 2012 at 1:14 pm
Yeah, now it’s clear !… And firstly I did not understand very much where there was the link with the title itself !!…
February 7th, 2012 at 2:08 pm
Hooray! the one who wrote is a cool guy..!
February 7th, 2012 at 3:09 pm
Are you interested in webmaster`s income?!…
February 7th, 2012 at 4:03 pm
I am glad that your blog is constantly evolving. Such posts only gain in popularity!…
February 7th, 2012 at 4:58 pm
Of course, I understand a little about this post but will try cope with it!!…
February 7th, 2012 at 5:55 pm
Youth rock band “Ranetki” says thank you for such a wonderful blog..!
February 7th, 2012 at 6:54 pm
I do`t regret that spent a few of minutes for reading. Write more often, surely’ll come to read something new!…
February 7th, 2012 at 7:47 pm
The material is on the five plus. But there is a minus! My internet speed 56kb/sek. The page was loading for about 40 seconds!…
February 8th, 2012 at 6:24 am
Totally agree with you, about a week ago wrote about the same in my blog..!
February 8th, 2012 at 8:37 am
I almost accidentally visited to this site, but stayed here for a long time. Stayed because everything was very interesting. Surely will share with all my friends!…
February 8th, 2012 at 10:40 am
Good day! I do not see the conditions of using the information. May I copy the text from here on my site if you leave a link to this page?!…
February 8th, 2012 at 11:17 am
order valium no prescription – purchase valium
February 8th, 2012 at 1:43 pm
order ambien no prescription – buy cheap online ambien
February 8th, 2012 at 5:52 pm
A unique note..!
February 8th, 2012 at 5:56 pm
Checkout Xrumer! At http://www.xrumer.mobi
February 8th, 2012 at 8:23 pm
As usual, the webmaster posted correctly..!
February 8th, 2012 at 9:00 pm
buy ambien online cheap – purchase ambien no prescription
February 8th, 2012 at 9:07 pm
order xanax cheap – xanax no prescription
February 9th, 2012 at 12:56 am
buy ambien no rx – purchase ambien online no prescription