What's calling Tween.start()?


(Dan M) #1

I was getting some funky errors in my game, and the only think I can figure is something is telling my tweens to autostart. I threw together a quick entity to test

public class TestEntity extends Entity 
{
	private var _varTween:VarTween;
	public function TestEntity() 
	{
		var i:Image = Image.createCircle(20, 0x00FF05);
		this.graphic = i;
		_varTween = new VarTween(finishedTween);
		_varTween.tween(this, "x", 100, 1);
		this.addTween(_varTween, false);
	}
	private function finishedTween():void
	{
		trace("Tween has finished");
	}
}

I have the same problem in this little sample:

  1. I never call _varTween.start();
  2. add _varTween with a false in this.addTween()
  3. All I do is add enity to a world
  4. Tween always starts and finishedTween() gets called

So what’s happening, do all tweens of an entity get started upon adding an entity to a world?


(Ultima2876) #2

It’s been a while since I’ve worked with them but I believe the _VarTween.tween() function call itself starts the tween. I don’t remember having to call start each time separately. Try moving the tween() call itself somewhere else.


(Jacob Albano) #3

I did some digging around in Flashpunk’s source. It seems like tween() calls start() automatically, which sets active to true. Thus, when you add it to the tweener, even if you tell it not to autostart, it’s already active and starts updating immediately. This seems like a bug to me.


Knockback (how to get the direction) [Solved]
(Ultima2876) #4

At the very least, it’s inconsistent with the behaviour of the Alarm tween type, which requires that you call start even after setting up the tween properties.


(Zachary Lewis) #5

Is this issue being tracked?


(Jacob Albano) #6

Not yet. I was going to open an issue after we got some more feedback on the topic.