Hello there,
I'm moving some playing cards around a top-down view of a table.
I had a tween set to run on the clicking of a card through frame script - two tweens, in fact - one regular (move card to new X & Y coords) and one with a yoyo(scale up, change DSF to give effect of height off the table). This all worked fine.
Now I'm putting the same Tweens into a class, so I can just call myCard.throwCard(x,y,etc). The tween calls haven't really changed, but the Yoyo effect in the second tween doesn't work, it just stops at the target values.
package {
import flash.events.*;
import flash.display.Sprite;
import flash.filters.DropShadowFilter;
import com.greensock.TweenMax;
import com.greensock.easing.*;
public class card2D extends Sprite {
private var startScale:Number = 1.1;
private var zoomScale:Number = 1.2;
private var myDropShadow:DropShadowFilter = new DropShadowFilter(1,80,0x000000,1,3,3,0.7);
public function card2D():void {
super();
this.scaleX=startScale;
this.scaleY=startScale;
this.mouseChildren=false;
this.filters = new Array(myDropShadow);
}
public function throwCard(target_x:Number, target_y:Number, target_rot:Number, tween_time:Number):void {
var thisCard = this;
var targetX = target_x;
var targetY = target_y;
var targetRot = target_rot;
var tweenTime = tween_time;
TweenMax.to (thisCard, tweenTime, {x:targetX, y:targetY, rotation:targetRot, ease:Cubic.easeOut});
TweenMax.to (thisCard, (tweenTime/2), {scaleX:zoomScale, scaleY:zoomScale, dropShadowFilter:{color:0x000000, alpha:1, blurX:12, blurY:12, strength:0.7, angle:80, distance:6}, yoyo:true});
}
}
}
There must obviously be something wrong with TweenMax, because I am an AS3 genius and I never make mistakes. (...ahem...!)
...I mean, of course, any help greatly appreciated. Thanks (oh, and awesome work, Jack).
Olly
EDIT: I've just rolled back to an old version of TweenMax (was using 11.12, rolled back to 10.12), and now it works. Pretty sure I was using v11 at some point with it working, altho which subversion I'm not sure. Any ideas?
EDIT 2: Despite my weak attempt at sarcastic humour in the above post, I think this actully might be a TweenMax issue after all ( I did update around the time I was converting my code to a class)... And I promise to stop adding 'edits' to my post (sorry!)