Original Edit I am wanting to know the best method for a making a movieClip fade way on the stage. I can guess how to do it in as2 (that's what I was taught in) but I'm unsure how to to develop my code below. As a guess I would assume to attach it to an enterFrame event.
Basically, over the course of 5 seconds if the user hasn't interacted with the balloon, it fades to nothing using alpha.
Any pointers or suggestions? I'm new to AS3. (please ignore the CLICK)
reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);
function fadeBalloon(event:MouseEvent):void
{
reset_balloon.alpha = .2;
}
Secondary Edit -----
//----
//Resetter btn ---------------------
//------------------------------------------
reset_btn.addEventListener(MouseEvent.CLICK, startover);
function startover(event:MouseEvent):void
{
//gotoAndPlay(2);
reset_balloon.visible = true;
}
//----
Object(root).reset_balloon.thereseter_btn.addEventListener(MouseEvent.CLICK, truestartover);
function truestartover(event:MouseEvent):void
{
gotoAndPlay(2);
//reset_balloon.visible = false;
}
TweenLite.delayedCall(5, handleTimeUp)
function handleTimeUp():void
{
TweenLite.to(reset_balloon, 2, {alpha:0});
}
reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);
function fadeBalloon(event:MouseEvent):void
{
//reset_balloon.alpha = .5;
TweenLite.killDelayedCallsTo(handleTimeUp);
TweenLite.to(reset_balloon, 2, {alpha:0.4});
}
If you don't mind using Tweens, I'd recommend TweenLite for this one.
//Add function called in 5 secs
TweenLite.delayedCall(5, handleTimeUp)
private function handleTimeUp():void
{
TweenLite.to(reset_balloon, 2, {alpha:0});
}
And if for some reason you want to kill pending delay call (for example on mouse click);
reset_balloon.addEventListener(MouseEvent.CLICK, fadeBalloon);
private function fadeBalloon(event:MouseEvent):void
{
TweenLite.killDelayedCallsTo(handleTimeUp);
}