Jump to content
Search Community

button function not working as expected

timaging test
Moderator Tag

Recommended Posts

Hi there-

 

so, I'm trying to get some stuff to fade out prior to my go to and play, but currently it's just going to and playing.

 

this is what I have so far:

 

btn_AFI.addEventListener(MouseEvent.ROLL_OVER, fl_MouseOverHandler01);

function fl_MouseOverHandler01(event:MouseEvent):void
{
TweenMax.to(over_AFI,  1, {alpha:1, ease:Expo.easeOut});
TweenMax.to(btn_Highlight,  1, {alpha:1, y:17, ease:Expo.easeOut});
}


btn_AFI.addEventListener(MouseEvent.ROLL_OUT, fl_MouseOutHandler01);

function fl_MouseOutHandler01(event:MouseEvent):void
{
TweenMax.to(over_AFI,  1, {alpha:0, ease:Quad.easeInOut});
}

btn_AFI.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene01);

function fl_ClickToGoToScene01(event:MouseEvent):void
{
var mainIntroOut:TimelineLite = new TimelineLite({repeat:0});


mainIntroOut.appendMultiple([new TweenLite(map_USA,  1, {alpha:1, ease:Quad.easeInOut}),
                          new TweenLite(border,  1, {alpha:1, ease:Quad.easeInOut}),
                          new TweenLite(over_AFI,  2, {alpha:1, ease:Quad.easeInOut})], 0, TweenAlign.START, 0.1);
MovieClip(this.root).gotoAndPlay(1, "sections");

}

 

 

does this appear to be correct? I can't seem to find any documentation on how to do this.

 

thank you-

Dave

Link to comment
Share on other sites

Hi Dave,

 

Just because your gotoAndPlay() comes after your TimelineLite code, doesn't mean the gotoAndPlay is going to wait for the timeline to end before it fires. What you need to do is trigger the gotoAndPlay() when the timeline is complete. There are a number of ways, below I am adding an onComplete callback function which calls the root's gotoAndPlay method and passes in frame:1 and scene:"sections" as parameters

 

var mainIntroOut:TimelineLite = new TimelineLite({onComplete:MovieClip(this.root).gotoAndPlay, onCompleteParams:[1, "sections"]});

 

 

or you could do something like:

 

var mainIntroOut:TimelineLite = new TimelineLite({onComplete:gotoASpecialPlace});

function gotoASpecialPlace():void{
      MovieClip(this.root).gotoAndPlay(1, "sections");
}

 

if you use TimelineMax there is an addCallback() method too: http://www.greensock.com/as/docs/tween/ ... dCallback() but for now the above solutions will work fine.

 

-Carl

Link to comment
Share on other sites

maybe i'm not understanding everything, but i think this should do:

btn_AFI.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene01);

function fl_ClickToGoToScene01(event:MouseEvent):void
{

//updated code
var mainIntroOut:TimelineLite = new TimelineLite({onComplete:MovieClip(this.root).gotoAndPlay, onCompleteParams:[1, "sections"]});

mainIntroOut.appendMultiple([new TweenLite(map_USA,  1, {alpha:1, ease:Quad.easeInOut}),
                          new TweenLite(border,  1, {alpha:1, ease:Quad.easeInOut}),
                          new TweenLite(over_AFI,  2, {alpha:1, ease:Quad.easeInOut})], 0, TweenAlign.START, 0.1);


}

 

in your initial question you mentioned that things should fade out, but it looks like the timeline you provided is setting the alpha of things to 1. just wanted to make sure that little bit wasn't causing an issue.

 

-c

Link to comment
Share on other sites

Thank You CARL! You are a rock star!

 

I see what you are doing now. I will absorb this concept now as best I can... thank you thank you thank you!

 

:o:o:o:o:o:o:lol::shock::shock::shock::shock::shock:

 

but now, I've done something elsewhere, and I'm expecting this white block to fade in but it's not, and just jumping out before the fade:

 

btn_AFI.addEventListener(MouseEvent.CLICK, fl_ClickToGoToScene0110);

function fl_ClickToGoToScene0110(event:MouseEvent):void
{
var mainIntroOut1002:TimelineLite = new TimelineLite({onComplete:MovieClip(this.root).gotoAndStop(1)});

mainIntroOut1002.append(new TweenLite(whiteOut,  1, {alpha:1, ease:Quad.easeInOut}));

}

 

this looks correct, right?

Link to comment
Share on other sites

sorry dave, I sometimes scroll quickly through the email notifications. i had stopped reading after "thank you thank you".

 

but yes, from what I can tell the code looks exactly like the other code that was working. Don't know what's wrong.

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