Jump to content
Search Community

gotoAndStop() doesn't call onUpdate of the label

Username test
Moderator Tag

Recommended Posts

Hi

 

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();
addChild(mySprite);
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);
mySprite.graphics.drawRect(0,0,220,220);
}

// this doesn't work, because drawGradient is not been calling
myTimeline.gotoAndStop(2);

// my dirty workaround
myTimeline.timeScale=0.001;
myTimeline.gotoAndPlay(2);
// 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

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...