Update function prevents animation from playing


(Bimbamm) #1

Hi everyone, I encountered a an issue with my animation. The problem is it is not playing. To figure out what the cause is I created a completely new project and used the same code and to my surprise it was working. The next step was to look for defective code. I commented every single function out one by one and came to the conclusion that my update function is the cause. So I continued to comment out the update function line by line until nothing was left but the animation was still not playing. I removed the update function completely and voila it was working.

The animation code is very simple:

var tvAni:Spritemap = new Spritemap(Assets.SCREEN, 640, 360);
tvAni.add("play", [0, 1], 9, true);
		
		TVent = new Entity;
		TVent.layer = 1;
		TVent.graphic = tvAni;
		tvAni.play("play");
		add(TVent);

and adding

override public function update():void
{}

was enough from preventing the animation to play. I have done animation successfully on other projects with update functions and there was no such issue. Any help is appreciated. Thanks in advance.


(Bimbamm) #2

I’ ve found my error and now I feel really really ashamed.

super.update()

is missing.

close/delete thread.


(Jacob Albano) #3

No need to delete the thread; this is a pretty common problem and someone might come here with the same issue in the future.

I should point out that if you’re using FlashDevelop you can let the code completion create overrides for you, which include a call to super. Just type override [function name] Enter and it’ll generate it automatically.


(Bimbamm) #4

This is really good to know. Thanks!