CTRL+ ENTER TO YOUR NEW MEDIA!
package { import flash.events.MouseEvent; import flash.display.Sprite; import flash.events.Event; import fl.controls.ComboBox; import flash.display.Stage; import fl.transitions.*; import fl.transitions.Tween; import fl.transitions.easing.*; public class simpleTween extends Sprite { private var ball_ins:ball; private var ballArr:Array = new Array(); private var cb:ComboBox = new ComboBox(); private var __stage:Stage; private var radian:Number = 120; private var __time:uint=2; private var twFn:Function; private var ballCount:Number=30; public function simpleTween(st:Stage) { __stage = st; for (var i:Number =0; i { ball_ins = new ball(); ballArr[i]=ball_ins; addChild(ballArr[i]); ballArr[i].visible = false; } /////////////////////create new ball object to stage 30 object if you want more ball change the value of ballCount var childs:Sprite = new Sprite(); childs.graphics.beginFill(0); childs.graphics.lineStyle(0, 0); childs.graphics.drawRect(0, 0, __stage.stageWidth,__stage.stageHeight); childs.graphics.endFill(); childs.alpha=0; addChild(childs) ////////////////////////create blank rect when click on it balls will flow on stage addChild(cb); cb.setSize(155, 22); cb.addItem( { label: "Strong.easeIn", data:1 } ); cb.addItem( { label: "Strong.easeOut", data:2 } ); cb.addItem( { label: "Strong.easeInOut", data:3 } ); cb.addItem( { label: "Regular.easeIn", data:4 } ); cb.addItem( { label: "Regular.easeOut", data:5 } ); cb.addItem( { label: "Regular.easeInOut", data:6 } ); cb.addItem( { label: "None.easeIn", data:7 } ); cb.addItem( { label: "None.easeOut", data:8 } ); cb.addItem( { label: "None.easeInOut", data:9 } ); cb.addItem( { label: "Elastic.easeIn", data:10 } ); cb.addItem( { label: "Elastic.easeOut", data:11 } ); cb.addItem( { label: "Elastic.easeInOut", data:12 } ); cb.addItem( { label: "Bounce.easeIn", data:13 } ); cb.addItem( { label: "Bounce.easeOut", data:14 } ); cb.addItem( { label: "Bounce.easeInOut", data:15 } ); cb.addItem( { label: "Back.easeIn", data:ballCount } ); cb.addItem( { label: "Back.easeOut", data:17 } ); cb.addItem( { label: "Back.easeInOut", data:18 } ); cb.selectedIndex = 10; //////////////assign data to combobox all data are the tween function you will choose the function for animate the ball twFn = fl.transitions.easing.Elastic.easeOut; cb.addEventListener(Event.CHANGE, FnSelected); childs.buttonMode = true; childs.addEventListener(MouseEvent.CLICK,startAnimFn); ///////add listenner to the blank rect } private function FnSelected(e:Event):void { // when the combobox was change the Tween function will change follow the combobox switch (cb.selectedItem.data) { case 1: twFn = fl.transitions.easing.Strong.easeIn; break; case 2: twFn = fl.transitions.easing.Strong.easeOut; break; case 3: twFn = fl.transitions.easing.Strong.easeInOut; break; case 4: twFn = fl.transitions.easing.Regular.easeIn; break; case 5: twFn = fl.transitions.easing.Regular.easeOut; break; case 6: twFn = fl.transitions.easing.Regular.easeInOut; break; case 7: twFn = fl.transitions.easing.None.easeIn; break; case 8: twFn = fl.transitions.easing.None.easeOut; break; case 9: twFn = fl.transitions.easing.None.easeInOut; break; case 10: twFn = fl.transitions.easing.Elastic.easeIn; break; case 11: twFn = fl.transitions.easing.Elastic.easeOut; break; case 12: twFn = fl.transitions.easing.Elastic.easeInOut; break; case 13: twFn = fl.transitions.easing.Bounce.easeIn; break; case 14: twFn = fl.transitions.easing.Bounce.easeOut; break; case 15: twFn = fl.transitions.easing.Bounce.easeInOut; break; case ballCount: twFn = fl.transitions.easing.Back.easeIn; break; case 17: twFn = fl.transitions.easing.Back.easeOut; break; case 18: twFn = fl.transitions.easing.Back.easeInOut; break; } } private function startAnimFn(m:MouseEvent)////////when you click on stage(blank rect) this function will called { __time=randRange(10,20)/10; //set time of tween class the ball will flow fast or slow cos this line I use random function for (var i:Number =0; i { var sc:Number=randRange(1,10)/10; var xp:Number=randRange(m.stageX-radian,m.stageX+radian); var yp:Number=randRange(m.stageY-radian,m.stageY+radian); ballArr[i].visible = true; ballArr[i].playFn(m.stageX,m.stageY,xp,yp,sc,sc,randRange(1,10)/10,__time,twFn);//call playFn function inside the ballExt class this function will call tween class to Animate the ball } } private function randRange(min:Number, max:Number):Number { var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min; return randomNum; } }}
object – The instance of an object in which to apply the tween. This can be any object, and is not just limited to movie clips.
property – The numeric property of the previous object in which to Tween. The property name is passed to the constructor as a string.
ease class and method – The type of tween and the method of ease applied to it. Flash comes bundled with 6 easing classes:
Back – Extends the animation over one or both ends of the tween.
Bounce – Creates a bouncing effect in the tween at one or both ends.
Elastic – Creates a mixture of the bounce and back classes. The animation is extended over and bounces back at one or both ends of the Tween.
Regular – Slower motion at one or both ends of the tween.
Strong – Similar to regular but is more pronounced when combined with the various easing methods.
None – A simple linear transition from a to b.
These six easing classes each have three methods to control the ease: easeIn – The ease is applied only at the start of the tween. easeOut – The ease is applied only at the end of the tween. easeInOut – The ease is applied at both the beginning and end of the tween. By combing the six easing classes with the three easing methods, we can create a possible 18 different effects for each property.
These six easing classes each have three methods to control the ease:
easeIn – The ease is applied only at the start of the tween.
easeOut – The ease is applied only at the end of the tween.
easeInOut – The ease is applied at both the beginning and end of the tween.
By combing the six easing classes with the three easing methods, we can create a possible 18 different effects for each property.
begin – The beginning value for the property in the tween.
end – The end value for the property in the tween.
duration – The duration of the tween. This value can either be specified as a number of frames or a number of seconds depending on the value of the next parameter.
use seconds – Specifies whether or not the duration parameter should be measured in frames or seconds. Requires a Boolean of either true (use seconds) or false (use frames).
Post a Comment
No comments:
Post a Comment