Jump to content


gotoAndStop() doesn't call onUpdate of the label

Recommended Posts



is there a way to gotoAndStop in a timeline and call the onUpdate-Method?


Check this runable example, problem in the last lines:

import com.greensock.*; 
import com.greensock.easing.*;
import flash.geom.Matrix;
import flash.display.*;

var myTimeline:TimelineMax = new TimelineMax({paused:true});
var colors:Object = {left:0xB8E46F, right:0x0066CC};

myTimeline.append(new TweenMax(colors, 3, {hexColors:{left:0xff9900, right:0x663399}, onUpdate:drawGradient}));

var mySprite:Sprite = new Sprite();
function drawGradient():void {
var m:Matrix = new Matrix();
m.createGradientBox(220, 220, 0, 0, 0);
mySprite.graphics.beginGradientFill(GradientType.LINEAR, [colors.left, colors.right], [1, 1], [0x00, 0xFF], m, SpreadMethod.PAD);

// this doesn't work, because drawGradient is not been calling

// my dirty workaround
// and then stops via event e.g.


Of course, you can call after gotoAndStop the method drawGradient manually. But I call the event in the timeline with parametres which are addicted to the timeline.


Thanks for every help.

Link to comment
Share on other sites

By default, gotoAndStop() and gotoAndPlay() suppress events as they move the virtual playhead to the new position, but that's easy to change by using the 2nd parameter ("suppressEvents"). Just set it to false like myTimeline.gotoAndStop("myLabel", false); See the ASDocs for more info: http://www.greensock.com/as/docs/tween/ ... elite.html

Link to comment
Share on other sites

Oh I overlooked this.

Perfect. :)

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.