Jump to content
Search Community

Restart or Replay after Tweens are complete

azpaul test
Moderator Tag

Recommended Posts

I made some progress this weekend. The code did not come out the way I thought it would but I am getting the results that I wanted and there doesn't seem to be a performance issue other than the initial load. There seems to be a 2 second delay but that is no big deal.

 

I am now able to utilize tweenMax and timelineMax to somewhat dynamically tween my symbols based on values of an xml file. It took me a a while to overcome that hurdle but it got me to the next stage.

 

At the beginning of my movie there is a counter that counts down, at the end of the counter it loads the xml file and tweens the data. After the last data is tweened, it needs to go back to the counter and start the whole process over. There will be a new xml file ready before the timer gets to 00:00 again.

 

My problem is I can not seem to make it loop. I have tried the gotandplay with no avail. Any suggestions? I am also not quite understanding how the event listeners work so I am reading up on those as well. I understand the purpose just not how to write the listeners. This may be a viable solution as well.

 

Here is my newest tween code. This is in a function that gets called for loading the xml data. I have a separate timer function and a function that makes all the symbols hidden that I don't need which clears the main stage for the tweening.

timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw0].x-15), y:(this["num" +draw0].y+25)}, {rotation:-30}]}), 2);
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["num"+ draw0], 1, {visible:false} ), -1.75);
			timeline.append(TweenMax.to(this["background"+draw0], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw0 + "Stroke"], 1, {visible:true} ), -1.75);				
			timeline.append(TweenMax.to(this["num"+ draw0 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1,  repeat: 1, delay: 0}), -1.);


			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ), -.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw1].x-15), y:(this["num" +draw1].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw1], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw1 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw1 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ), -.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw2].x-15), y:(this["num" +draw2].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw2], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw2 + "Stroke"], 1, {visible:true} ),-1.75);
			timeline.append(TweenMax.to(this["num"+ draw2 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1, repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw3].x-15), y:(this["num" +draw3].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw3], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw3 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw3 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw4].x-15), y:(this["num" +draw4].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw4], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw4 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw4 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw5].x-15), y:(this["num" +draw5].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw5], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw5 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw5 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw6].x-15), y:(this["num" +draw6].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw6], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw6 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw6 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw7].x-15), y:(this["num" +draw7].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw7], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw7 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw7 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw8].x-15), y:(this["num" +draw8].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw8], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw8 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw8 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw9].x-15), y:(this["num" +draw9].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw9], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw9 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw9 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.appendMultiple ( [ TweenMax.to(this["num" +draw0], 1, {alpha:0, delay: -1}),
									   					TweenMax.to(this["num" +draw1], 1, {alpha:0}),
														TweenMax.to(this["num" +draw2], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw3], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw4], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw5], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw6], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw7], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw8], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw9], 1, {alpha:0} )],  1, TweenAlign.START, 1 );

Thanks!

Link to comment
Share on other sites

There's a 2-second initial delay because you set the offset of the first tween to 2 in the append().

 

If you want a TimelineMax to repeat, you can simply use its "repeat" property. So to make it repeat once, use 1. For twice use 2, etc. For infinitely use -1.

 

Does that answer your question?

Link to comment
Share on other sites

Hi Jack,

 

When the movie starts, i cal a function for a clock to run. This clock runs before the function that has the tweens. Using a trace statement verifies that the tweens using tweenMax has not run yet. I figured it is taking the long to render and display the graphics even though the code is running right away.

 

I tried using the repeat to to -1 and that only repeats the tweens unless I used the argument incorrectly. Should it take the whole movie as to when it was first opened? That is what I am looking to accomplish. Not really just repeat but restart, because the xml load function needs to load a new set of data.

 

Here is the entire code not just the tweens.

 

Thanks.

 

include "stroke_off.as";
include "timer.as";


import com.greensock.*;
//import com.greensock.easing.*;
//import com.greensock.TimelineLite;

var timeline:TimelineLite = new TimelineMax();

var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
//var fields:Array;
var draw0:String;   var draw1:String;   var draw2:String;   var draw3:String;   
var draw4:String;   var draw5:String;   var draw6:String;   var draw7:String;   
var draw8:String;   var draw9:String; 

trace ("num2Stroke visible is set to " +num2Stroke.visible);


strokeOff();

trace ("num2Stroke visible is set to " +num2Stroke.visible);
//var ingrd:Array = [ing1, ing2, ing3];

xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
//A bit of error handling in case the XML goes missing;
xmlLoader.addEventListener(IOErrorEvent.IO_ERROR, xmlError);
xmlLoader.load(new URLRequest("data.xml"));
//numbers = new Array(num1, num2);
//fields = new Array("one","two");

function xmlError(e:IOErrorEvent):void{
//Just letting the user know something's screwed
trace("Error Loading XML");
}

function LoadXML(e:Event):void{
xmlData = new XML(e.target.data);
ParseContent(xmlData);
}

function ParseContent(contentInput:XML):void
{
trace("XML Contents");
trace("------------------------");

var numberList:XMLList = contentInput.numberitem;
//trace ('length is ' + numberList.length());
gnumber.text = contentInput.gamenumber;
trace ("Game Number is " +gnumber.text);

for (var i:int = 0; i < numberList.length(); i++)	{
	//trace ("I is " + i);
	//trace ("List Length is " + numberList.length());
	var numberItem:XML = numberList[i];
	draw0 = numberList[0];    draw1 = numberList[1];     draw2 = numberList[2];    draw3 = numberList[3];    
	draw4 = numberList[4];    draw5 = numberList[5];     draw6 = numberList[6];    draw7 = numberList[7];    
	draw8 = numberList[8];    draw9 = numberList[9];     /*draw2 = numberList[2];    draw2 = numberList[2];    */
	//this["num"+ numberList[i] + "Stroke"].visible = false;



			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw0].x-15), y:(this["num" +draw0].y+25)}, {rotation:-30}]}), 2);
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["num"+ draw0], 1, {visible:false} ), -1.75);
			timeline.append(TweenMax.to(this["background"+draw0], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw0 + "Stroke"], 1, {visible:true} ), -1.75);				
			timeline.append(TweenMax.to(this["num"+ draw0 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1,  repeat: 1, delay: 0}), -1.);


			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ), -.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw1].x-15), y:(this["num" +draw1].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw1], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw1 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw1 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1,  repeat: 1, delay: 0}), -1);

			/*timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ), -.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw2].x-15), y:(this["num" +draw2].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw2], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw2 + "Stroke"], 1, {visible:true} ),-1.75);
			timeline.append(TweenMax.to(this["num"+ draw2 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: 0, yoyo: 1, repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw3].x-15), y:(this["num" +draw3].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw3], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw3 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw3 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw4].x-15), y:(this["num" +draw4].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw4], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw4 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw4 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw5].x-15), y:(this["num" +draw5].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw5], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw5 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw5 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw6].x-15), y:(this["num" +draw6].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw6], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw6 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw6 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw7].x-15), y:(this["num" +draw7].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw7], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw7 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw7 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw8].x-15), y:(this["num" +draw8].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw8], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw8 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw8 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);

			timeline.append(TweenMax.to(kenoBall, 1, {x:1364.75, y:90, rotation:0}));
			timeline.append(TweenMax.to(kenoBall, .70, {alpha : 1} ),-.25);
			timeline.append(TweenMax.to(kenoBall, 4, {bezier:[{x:600, y:-150}, {x:(this["num" +draw9].x-15), y:(this["num" +draw9].y+25)}, {rotation:-30}]}));
			timeline.append(TweenMax.to(kenoBall, 1, {alpha : 0} ));
			timeline.append(TweenMax.to(this["background"+draw9], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw9 + "Stroke"], 1, {visible:true} ), -1.75);
			timeline.append(TweenMax.to(this["num"+ draw9 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, z: -10, yoyo: 1,  repeat: 1, delay: 0}), -1);*/


			timeline.appendMultiple ( [ TweenMax.to(this["num" +draw0], 1, {alpha:0, delay: -1}),
									   					//TweenMax.to(this["num" +draw1], 1, {alpha:0}),
														/*TweenMax.to(this["num" +draw2], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw3], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw4], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw5], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw6], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw7], 1, {alpha:0} ),
														TweenMax.to(this["num" +draw8], 1, {alpha:0} ),*/
														TweenMax.to(this["num" +draw1], 1, {alpha:0} )],  1, TweenAlign.START, 1 );





}


}

Link to comment
Share on other sites

If you want to restart the entire MovieClip timeline, yes, you need to gotoAndPlay(1). But the problem is that if you tweened objects to new positions/alphas/whatever, moving the playhead on the MovieClip timeline won't automatically revert those. So you need to either manually do that or just put an empty frame at the very beginning of the MovieClip so that when it reaches frame 2, it forces every object to re-initialize.

Link to comment
Share on other sites

Hi Jack,

 

If I understand your reply correctly, at the end of my last tween I put

 timeline.gotoAndPlay(1);

 

Then on my actionscript layer I put a blank frame, not a key frame?

 

When I do either, nothing happens for me. The last tween completes and then the movie seems to stop. When I used a key frame, I was able to put 1 single line of code so I used a trace statement. This trace never showed.

 

On the very bottom of my actionscript I have stop(); this is out side of the function. With out this the movie appears to infinitely loop on frame 1.

 

This is my last tween.

timeline.append(TweenMax.to(this["num"+ draw1 + "Stroke"], 1, {scaleX: 2.5, scaleY: 2.5, yoyo: 1, repeat: 1}), -1);

timeline.gotoAndPlay(1);

Link to comment
Share on other sites

No no, you gotoAndPlay(1) on the MovieClip timeline, not the TimelineLite/Max. And you make sure EVERY layer on that MovieClip timeline has a keyframe on frame 1 that is completely blank. Nada. Nothing. Zilch. You should probably kill() your timeline actually on the last frame before you gotoAndStop(1) on the MovieClip timeline.

Link to comment
Share on other sites

I am using trace statements to follow the progress and I see it looping through the functions. That is good, that part is working.

 

But, the tweens no longer have any time to run. It is like the script to looping so fast that it does not have time to finish or start the tweens???

Also the clock in the timer exits the function pretty much right away. Again, it appears that the goto statement is infact reinitializing everything before it has completed.

 

Here's what I did,

 

Put the following code the bottom of my script

timeline.kill();
trace ("Timeline killed");
gotoAndPlay(1);
stop();

Then on the timeline of the main mc I converted all 1st frames to empty key frames. I have 6 layers. All 1st frames were blank except the Actionscript layer. This one I do not have a blank key frame on. It did not seem to matter when I did so I removed it.

 

Here is what a correct output looks like from my traces. Tweens fire off in sequence with no problems.

Get Time Function

Stroke Off Function

Timeline killed

XML Contents

------------------------

Game Number is 28

Number Drawn is 1

Number Drawn is 2

First Tween Done

Second Tween Done

Seconds are 01

Seconds are 00

Second in If statement 00

 

Here is an output with the goto statement

Get Time Function

Stroke Off Function

Timeline killed

XML Contents

------------------------

Game Number is 28

Number Drawn is 1

Number Drawn is 2

First Tween Done

Second Tween Done

 

Get Time Function

Stroke Off Function

Timeline killed

XML Contents

------------------------

Game Number is 28

Number Drawn is 1

Number Drawn is 2

First Tween Done

Second Tween Done

Seconds are 01

Seconds are 01

Seconds are 02

 

Notice no Seconds. It seem to not even get that far in the function before it was initialized. But further down in the output, because it does run indefinitely, seconds will appear here and there. Not both, sometime both maybe one. Seconds sometimes shows as a negative number. The stage flickers as it is running through.

 

Is there an option with tweenmax that detects when a motion is complete to call a function. Then I could put the goto statement in a function. That way I know it is only getting called when the tween's motion is complete.

 

Thanks. Sorry this was so long, I wanted to give a good idea of what was happening.

Link to comment
Share on other sites

I got it... Have a few issues I have to work through like a flicker or something but the way I did this is from another post I simply added to the last tween

 

onComplete: nextRound

--- with out the parens... I saw that mistake in the post.

 

Sure enough now that the the goto is in a function it fires off only when the last tween motion is complete. YES!

 

But like I said I have a flicker issue and some of the symbols are not visible after the 1st cycles...

 

I will keep you posted!

 

Thanks!

Link to comment
Share on other sites

Hi Jack,

 

I was able to work through all the issues. I had this weird flicker that was the stage color either coming in front of my main background image or that background image was becoming transparent. It only was happening when I was going to frame 1 on from the nextRound function. I ended up having to delete the entire layer and I used a jpg instead of a png for that image. Really weird.

 

Another weird thing is when I test the movie with in flash, the timer gets messed up. It slows down and skips, but only when it runs from in the cs5. It will sometime go negative on me so I have to put a fail safe in the if statement.

 

If I play the swf by alone, no skipping. Again, weird. I am wondering if I will have some issues when it is on the server? I will soon find out.

 

Thanks for all your help. Oh, can you tell me if a 1meg swf is considered large?

Link to comment
Share on other sites

Tough to know what's causing your timer issue without seeing your FLA but I'm sure there's a reason for it.

 

Yeah, 1MB would be considered pretty big but it really depends on what it is and who your audience is. For a video, that's really small. For a banner ad, it's insanely huge. :) I know yours is a game, but I'm not sure about the details, the flow, the audience, etc. You could have a 1MB swf but if the first interactive part shows up in the first 5 seconds and the user can start their game while the rest of it loads, that's much different than if they have to wait for the entire 1MB file to download first. You could look into splitting things into several chunks and use LoaderMax to subload stuff. Just a thought.

Link to comment
Share on other sites

Hi Jack,

 

Thanks for all your help. I think the original fla was working with was messed up some how. When I broke down the problems into an isolated fla that dealt strictly with the function I wanted to do, it worked. But when I copied it into the original fla, it would not. So, I just built of the working model. I was then able to pass variables and properties that I could not otherwise.

 

The gotoAndPlay worked great except I did not foresee a splash screen needed at the end of the tweens. Because the entire movie was initialized I lost the values from my array. So now that I had good working model to work from, I was able to call specific functions with the onColomplete argument in the last tween. I was not able to move between functions so easily in the original model and being new to this, did not pick up something was wrong.

 

I now have the movie go through all the tweens and at the end, throw a splash page with stats and restart the counter. and do it all over again.

 

The issue with the clock maybe how the timer is written. I have another sample code that I am going to replace it with which drops the code to about 8 lines versus 30 or so. Bu it only does it in cs5 and I can see the lag when the output put is being written to the window. If I run the swf directly, it runs smooth. I added a fail safe that if he counter goes <0 the it acts as though it is 0. I have 4 Gigs memory so I don't think it is a memory issue and I did not see high cpu usage either.

 

Being very graphics intensive, it is almost 2 megs now and being that it is a non interactive display only, it loads pretty quick. It will always be loaded from local drive on a unix or windows machine. I will have a demo at some point on my website so I will look at the loadMax for that. I have about 1.5 burst and then throttle back to about 512K upload speed on my server.

 

As I am coming to almost a completion on this project, thanks again for all your help, suggestions and guidance!

 

I am wondering though if I could have written the tweening more efficiently. I know you need to have a tween statement for every tween, but could you have a routine that allows you to say create a virtual tween without having to code a line for every tween? My final project ended up with 20 blocks of 7 lines of code and the only thing that changed is the symbol name.

 

Talk to you soon.

Link to comment
Share on other sites

...could you have a routine that allows you to say create a virtual tween without having to code a line for every tween? My final project ended up with 20 blocks of 7 lines of code and the only thing that changed is the symbol name.

 

I'm not sure what you mean by a "virtual tween". You don't have to code a line for every property tween - you can combine multiple properties in a single tween (like if you want to tween an object's x and y and alpha properties at the same time). TweenMax also has an allTo() and allFrom() and allFromTo() that allow you to pass in an array of objects to tween and you can tween them all to the same values with one line of code. You can even stagger their start times.

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