| Now that we have set the foundation for the Tween animation in our FlashR project, we are ready to code the ActionScript that will run the animation. First, we will add an Event Listener to listen for a mouse click. When a mouse click occurs, a function will run that will create the Tween. Open the project that you have been working on with the previous tutorial and let's get started. First, we need to decide what will start the Tween animation. Will it start as soon as the Flash file loads into the browser or will it be started by a certain event. Let's use the second method by adding an Event Listener to the stage.
newRec This argument identifies the object that we will animate. "x" This argument identifies the object's property that we want to control, the x location of the object. Back.easeIn This argument identifies the type of easing that we want to use. There are several easing types, or classes, that come with the fl.transitions.easing package. They are Back, Bounce, Elastic, None, Regular and Strong. Here we are using the Back class. Back.easeIn Notice that the Back class is followed by a period and then the easeIn method. There are three easing functions to choose from including easeIn, easeInOut and easeOut. 100 This next argument will give Flash the initial x location for the object on the stage. This is the spot where the animation will begin. Because, our rectangle is not on the stage until we click the mouse, we are also telling Flash where to draw the rectangle on the stage. 150 This argument gives Flash the end location for the Tween. We will be moving the rectangle 50 pixels on the stage. So we need to set this argument to 150. Another option would be to move the rectangle to the location on the stage where we clicked the mouse. 2 This argument tells Flash the duration of the Tween animation. This number value can refer to either seconds or frames, depending on the value of the last argument. true This argument tells Flash what measurement to use for the Tween. When this argument is set to true, Flash will measure in seconds. For a false value, Flash will measure the duration in frames. The second statement does the same for the y property of the object. Here is the code for our sample Tween.
← Back Join us in the Flash forum. | |||||||

