Hi,
I developed a test class to experiment how to control different TimelineMax instances with sliders. Test class works as expected.
Then, in the scenario where I use the code the TimelineMax instances start delayed.
In this implementation i didn't change anything other than from where i get the actual symbol definitions ( from a preloader instead of having the classes inside the same test class )
So, in the test class if I call _createTimeline( holder, 1,5, false ) the tweens execute inmediatly.
But in the implementation they have a delay...what could be the cause of that?!
Code:
//This is how i set up different TimelineMax instances, and then relate them to a particular slider instance.
private function _createTimeline( holder:DisplayObjectContainer, symbolId:int, totalSymbols:int, paused:Boolean = true ):void {
var clip:MovieClip, symbol:SymbolProxy;
var tm:TimelineMax = new TimelineMax( { paused:paused } );
var colors:Array = ColorUtils.instance.getRandomPalateOf( _colors[symbolId], 5, 0.4, 1.4);
var alpha:Number, scale:Number, tint:Number;
for ( var i:int = 0; i < totalSymbols; i++) {
//create movieclip instance.
clip = new _symbols[ symbolId ]();
//wrap it inside a proxy class that handles effects on tweening properties.
symbol = new SymbolProxy( clip, holder );
//random initial positions.
symbol.initX = clip.x = MathUtils.instance.randomRangeNum( 0, (0 + holder.width - clip.getBounds(clip).width) / 2 );
symbol.initY = clip.y = MathUtils.instance.randomRangeNum( 0 + clip.height, 0 + holder.height - clip.getBounds(clip).height );
//random final positions.
symbol.endX = MathUtils.instance.randomRangeNum( (0 + holder.width - clip.getBounds(clip).width) / 2, 0 + holder.width - clip.getBounds(clip).width );
symbol.endY = MathUtils.instance.randomRangeNum( 0 + clip.getBounds(clip).height, 0 + holder.height - clip.getBounds(clip).height );
holder.addChild( clip );
alpha = MathUtils.instance.randomRangeNum( 0.7, 0.9, 2 );
scale = MathUtils.instance.randomRangeNum( .5, 4.3, 2);
tint = colors[i];
tm.addChild( new TweenMax( symbol, 2, { x:symbol.endX, y:symbol.endY, alpha:alpha, rotation:360, scaleX:scale, scaleY:scale } ) );
tm.addChild( new TweenMax( symbol.source, 2, { tint:tint } ) );
}
//store the TimelineMax instance related to a slider id.
_timelines[ "sliders"+symbolId ] = tm;
}
//here, we handle the timeline current time update.
private function _handleSliders( e:Event ):void {
var sl:HSlider = e.target as HSlider;
//retrieve TimelineMax instance from slider's id
var tm:TimelineMax = _timelines[ sl.name ];
var t:Number = ( 2 * sl.value ) / 100;
tm.currentTime = t;
}