AlexDrop Posted November 11, 2009 Share Posted November 11, 2009 Hi guys, please forgive my poor english I wrote this code import com.greensock.* import com.greensock.plugins.*; import com.greensock.easing.*; TweenPlugin.activate([EndArrayPlugin]); var mioArray:Array = [0]; var elementi:Number=10 var tempi:Array = new Array() function aggiungi(){ tempi.push(mioArray[0]) } TweenLite.to(mioArray, elementi, {endArray:[3], onUpdate:aggiungi, onComplete:anima, useFrames:true, ease:Regular.easeOut}) (I've also wrote a little class if you are interested in) What this code do, is to tween in an array an interval of numbers. Whit this array next I will tween my object like this function anima(){ for (var i=0;i var cc:MovieClip = _root.attachMovie("cerchio", "c"+i,i); cc._y = (cc._height+5)*i; TweenLite.from(cc, 2, {_x:Stage.width, ease:Bounce.easeOut, delay:tempi[i]}); } } So I don't have a linear start of the tween (something like delay: i*.3), but a start with an ease function. The only "problem" with this code is that we have to wait for the frames in order to create the array (TweenLite.to(mioArray, elementi, {endArray:[3], onUpdate:aggiungi, onComplete:anima, useFrames:true, ease:Regular.easeOut})) There could be a way in order to have te array more speedily Link to comment Share on other sites More sharing options...
GreenSock Posted November 11, 2009 Share Posted November 11, 2009 Sorry, I didn't understand the question/problem Link to comment Share on other sites More sharing options...
AlexDrop Posted November 18, 2009 Author Share Posted November 18, 2009 Don't bother, I tried to use TweenLite to do something that i could do with the ease equation. If someone is interested in, this class return an array with an interval of time that go on with an ease equation example import com.greensock.easing.* import fl.transitions.easing.Regular; var elementi:Number=10 var time:Number = 3 var delay:Number = 1 var tempo = easeTime.getTime(elementi, Regular.easeOut, time, delay) trace(tempo) //1.57,2.08,2.53,2.92,3.25,3.52,3.73,3.88,3.97,4 var tempo = easeTime.getTime(10, Linear.easeOut, 10, 1) trace(tempo) //2,3,4,5,6,7,8,9,10,11 var tempo = easeTime.getTimeOff(10, Linear.easeOut, 10, 1) trace(tempo) //11,10,9,8,7,6,5,4,3,2 And so on... In nice to use the array as a delay for the tweens in a cicle elementi = arrayMC.length var tempo = easeTime.getTime(elementi, Regular.easeOut, 2,0) for (i<0;i TweenLite.to(arrayMC[i], .5, {_x+"500", delay:tempo[i]}) } The Class /* ################# # Name: easeTime Class # Author: Pomili Alessandro # Date: 17 Nov 20009 # Description: La classe restituisce un array nel quale gli indici contengono un intervallo di numeri, con progressione calcolata sulle funzione di ease ########### */ package { import flash.events.*; import fl.transitions.easing.Regular; public class easeTime { public function easeTime ():void { throw (new Error("La classe è di tipo singleton e non può essere istanziata")); } //restituisce un intervallo tra delay e tempo (es tra 0 e 5, o tra 3-7) public static function getTime(elementi:Number, myease:Function=null, tempo:Number=1, delay:Number=0):Array { var arrayTempo = new Array(); if (myease==null) { myease = Regular.easeOut}; for (var i:uint = 1; i <= elementi; i++) { //myease(i, delay, ((i/elementi)/i)*elementi, elementi)*tempo // questa istruzione calcola il valore di ease sul numero degli elementi tra l'intervallo di tempo 0, e tempo) arrayTempo.push (Math.round(myease(i, delay/tempo, ((i/elementi)/i)*elementi, elementi)*tempo*1000)/1000); //round*1000/1000 arrotonda a 3 decimali } return arrayTempo; } //restituisce un intervallo tra tempo e delay public static function getTimeOff(elementi:Number, myease:Function=null, tempo:Number=1, delay:Number=0):Array { var arrayTempo:Array = getTime(elementi, myease, tempo, delay) return arrayTempo.reverse() } //restituisce un intervallo dove i lati dell'array contengono gli intervalli più piccoli public static function getTimeCenter(elementi:Number, myease:Function=null, tempo:Number=1, delay:Number=0, blReverse:Boolean=false):Array { var meta_elementi:Number = Math.ceil(elementi/2) var arrayMetaTempo:Array = new Array() if (blReverse){ arrayMetaTempo = getTime(meta_elementi, myease, tempo, delay) }else{ arrayMetaTempo = getTimeOff(meta_elementi, myease, tempo, delay) } var reverse:Array = reverse(arrayMetaTempo) if (elementi%2!=0){ //se gli elementi sono dispari tolgo il primo indice reverse.shift() } var arrayTempo:Array=arrayMetaTempo.concat(reverse) return arrayTempo } //restituisce un intervallo dove i lati dell'array contengono gli intervalli più grandi public static function getTimeSide(elementi:Number, myease:Function=null, tempo:Number=1, delay:Number=0):Array { return getTimeCenter(elementi, myease, tempo, delay, true) } //crea una copia inversa dell'array passato private static function reverse(arrayTempo:Array):Array { var reverse:Array = new Array() reverse = reverse.concat(arrayTempo) return reverse.reverse() } } } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now