Jump to content
Search Community

Yoyo no go(go)... [SOLVED]

ollywood test
Moderator Tag

Recommended Posts

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

Link to comment
Share on other sites

 

...er, so after mentioning it to someone who knows a lot more about ActionScript than me (which is obviously a helluva lot, because remember I am an AS3 genius...), he's pointed out that the new v11 use of Yoyo requires Repeat to also be defined... so it's working now. And, yes, it's true, I'm a complete boob. Who doesn't read the docs properly.

 

 

Hope this helps others, and thanks again to Mr Greensock and his Fantabulous Tweening Machine...

Link to comment
Share on other sites

Ha ha. No worries. I guarantee you're not the first person to miss that. Sorry about any confusion the switch caused, but I think the new way is more intuitive overall. And for anyone else wanting to know about other changes made in v11, check out http://blog.greensock.com/v11/. The VAST majority of things work exactly the same way they always did, but there are a few minor "gotchas" to watch out for, but they're ultimately improvements (trust me) :)

 

Thanks for letting us know you figured it out. Happy tweening.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...