PDA

View Full Version : TweenLite Sequence problem



urieljuliatti
June 17th, 2009, 03:57 PM
Hello everybody.. I'm developing a project and having some problems to manipulate the TWEENLITE...

Check out my code and what it does:



// ++++++++++++ Navigations ++++++++++++++

// -- BOTOES -- //

fotos.addEventListener(MouseEvent.CLICK, navigate);
fotos.buttonMode = true;
fotos.addEventListener(MouseEvent.ROLL_OVER, btnOver);
fotos.addEventListener(MouseEvent.ROLL_OUT, btnOut);

// -- Convide -- //

convide.addEventListener(MouseEvent.CLICK, navigate);
convide.buttonMode = true;
convide.addEventListener(MouseEvent.ROLL_OVER, btnOver);
convide.addEventListener(MouseEvent.ROLL_OUT, btnOut);

// -- Downloads -- //

downloads.addEventListener(MouseEvent.CLICK, navigate);
downloads.buttonMode = true;
downloads.addEventListener(MouseEvent.ROLL_OVER, btnOver);
downloads.addEventListener(MouseEvent.ROLL_OUT, btnOut);

// -- INFO -- //

info.addEventListener(MouseEvent.CLICK, navigate);
info.buttonMode = true;
info.addEventListener(MouseEvent.ROLL_OVER, btnOver);
info.addEventListener(MouseEvent.ROLL_OUT, btnOut);

// -- FUNÇÃO NAVIGATE -- //



function navigate(event:MouseEvent):void{
if(event.target.name == "fotos" ){
// Navegação dinâmica pelo nome do SWF / Instância
myLoader.load(new URLRequest("fotos.swf"));
}// end if

if(event.target.name != "fotos"){
switch(event.target.name) {
case "convide":
TweenLite.to(convide, 0.2, {x:404.6, y:148.3, scaleX:1, scaleY:1, alpha:1, ease:Bounce.easeOut});
TweenLite.to(fotos, 1, {x:500, y:104, scaleX:1, scaleY:1, alpha:0, ease:Strong.easeOut, delay:0.1});
TweenLite.to(downloads, 1, {x:500, y:220, scaleX:1, scaleY:1, alpha:0, ease:Strong.easeOut, delay:0.2});
myLoader.load(new URLRequest("convide.swf"));
break;
case "downloads":
trace("downloads");
break;
case "info":
myLoader.load(new URLRequest("info.swf"));
break;
}
}


}

// ++++ FUNCTION OVER/OUT +++++

function btnOver (event:MouseEvent):void {
if(event.target.name == "fotos" ){
TweenLite.to(fotos, 0.5, {x:399, y:101, scaleX:1.5, scaleY:1.5, alpha:0.5, ease:Back.easeOut});
trace("fotos Over");
}// end if
if(event.target.name != "fotos"){
switch(event.target.name){
case "convide":
TweenLite.to(convide, 0.5, {x:404.6, y:128.3, scaleX:1.5, scaleY:1.5, alpha:0.5, ease:Back.easeOut});

trace("over Convide");
break;
case "info":
TweenLite.to(info, 0.5, {x:402.2, y:250.8, scaleX:1.5, scaleY:1.5, alpha:0.5, ease:Back.easeOut});
break;
}// end Switch
} // end if
}

function btnOut (event:MouseEvent):void {
if(event.target.name == "fotos" ){
TweenLite.to(fotos, 0.8, {x:399, y:121, scaleX:1, scaleY:1, alpha:1, ease:Bounce.easeOut});
trace("fotos Out");
}// end if
if(event.target.name != "fotos"){
switch(event.target.name){
case "convide":
TweenLite.to(convide, 0.8, {x:404.6, y:148.3, scaleX:1, scaleY:1, alpha:1, ease:Bounce.easeOut});
trace("out Convide");
break;
case "info":
TweenLite.to(info, 0.8, {x:402.2, y:260.8, scaleX:1, scaleY:1, alpha:1, ease:Bounce.easeOut});
break;

}// end Switch
} // end if
}


The problem is around here:



if(event.target.name != "fotos"){
switch(event.target.name) {
case "convide":
TweenLite.to(convide, 0.2, {x:404.6, y:148.3, scaleX:1, scaleY:1, alpha:1, ease:Bounce.easeOut});
TweenLite.to(fotos, 1, {x:500, y:104, scaleX:1, scaleY:1, alpha:0, ease:Strong.easeOut, delay:0.1});
TweenLite.to(downloads, 1, {x:500, y:220, scaleX:1, scaleY:1, alpha:0, ease:Strong.easeOut, delay:0.2});
myLoader.load(new URLRequest("convide.swf"));
break;
case "downloads":
trace("downloads");
break;
case "info":
myLoader.load(new URLRequest("info.swf"));
break;
}


It LOADS quickly.. I need to load AFTER the tween effects (in blue)..

How do I do it works?!

Any help would be appreciated!

Uriel.

JonnyR
June 18th, 2009, 02:32 AM
Uriel,

TweenLite allows you to supply a callback function in the Tween Arguments Object. For Example:



TweenLite.to(downloads, 1, {
x:500,
y:220,
scaleX:1,
scaleY:1,
alpha:0,
ease:Strong.easeOut,
delay:0.2,
onComplete: this.onDownloadsTweenComplete
});


For more information on using callback functions, please refer to the TweenLite docs over at greensock's blog: http://blog.greensock.com/tweenliteas3/

Jonny.

urieljuliatti
June 18th, 2009, 08:44 AM
I tryied a callback function... But it didn't work...

greensock
June 19th, 2009, 08:35 PM
Please provide more details other than "it didn't work". Did you use the "onComplete" special property? Like

TweenLite.to(mc, 1, {x:100, onComplete:myFunction});
function myFunction():void {
//code to run when tween completes
}