Jump to content

Search In
  • More options...
Find results that contain...
Find results in...

Delay not respected in TweenMax.fromTo while play(0) called

Recommended Posts

In my app, I'm storing tweens, to be played later on, and lately I needed to add delay to those tweens. Shouldn't those delays be respected when tweens being played manually, or should I play them in a diffrent way. It would be sad however if I had to treat delayed tweens diffrent than those without delay.


Below is the code that does not work the way I expect it to work.

 * Created by jakubgondek on 2015-02-25.
import com.greensock.TweenMax;

import flash.display.Sprite;
import flash.events.MouseEvent;

public class TestDelay extends Sprite
	private var sprite0 : Sprite = new Sprite();
	private var tween0:TweenMax = TweenMax.fromTo(sprite0, 3, {alpha: 1}, {alpha: .1, paused: true, delay: 3});

	public function TestDelay()

		sprite0.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownListener);

	private function drawSquare(target:Sprite)
		with (target.graphics)
			drawRect(0, 0, 100, 100);

	private function mouseDownListener(e:MouseEvent):void
Link to comment
Share on other sites

When you call play(0), that's telling it to play from the zero position (the start). If you want to restart the tween and include the delay, just use the restart() method and set the "includeDelay" parameter to true, like:

  • Like 1
Link to comment
Share on other sites

I had concerns if it'll work for tweens that haven't been started, but it works as far as I can see. Thanks for such a fast response Jack.

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.