Solved

Flash - fade-out

Posted on 2011-03-22
9
341 Views
Last Modified: 2012-08-13
Hello,

I've created a fade in with the timeline, calling it in a function with object.play();
How can I, with another function, reverse the timeline?

So that I get a fade-out instead of fade-in?

So instead of playing frame 1-30, it goes 30-1
0
Comment
Question by:ErnstJacobs
  • 5
  • 2
  • 2
9 Comments
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35191065
Create a recursive function like this:
function reverse():void
{
   if( object.currentFrame > 1 ){
        object.gotoAndStop( object.currentFrame - 1 );
        reverse();
   }
}

Open in new window


Warm Regards
Deepanjan Das
0
 

Author Comment

by:ErnstJacobs
ID: 35191179
I've done the following
function btnOutFunction(e:MouseEvent) {
	   if( txtObjectMC.currentFrame > 1 ){
        trace(txtObjectMC.gotoAndStop( txtObjectMC.currentFrame - 1 ));
        btnOutFunction(e);
   }
}

Open in new window


But it gives as output "undefines, undefined, undefined, etc."
maybe it needs a delay? but how?
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35191261
try this:
function btnOutFunction(e:MouseEvent) {
          reverse();
}

function reverse() {
           if( txtObjectMC.currentFrame > 1 ){
        trace(txtObjectMC.gotoAndStop( txtObjectMC.currentFrame - 1 ));
        reverse();
   }
}

Open in new window


Warm Regards
Deepanjan Das
0
 
LVL 1

Accepted Solution

by:
smabudhahir earned 250 total points
ID: 35191309
Try this..

function btnOutFunction(e:MouseEvent) {
   txtObjectMC.addEventListener(Event.ENTER_FRAME, onObjEnterFr);
}
function onObjEnterFr(e:Event):void{
	if( txtObjectMC.currentFrame > 1 ){
		 txtObjectMC.gotoAndStop( txtObjectMC.currentFrame - 1 );
	}else{
		txtObjectMC.removeEventListener(Event.ENTER_FRAME, onObjEnterFr);
	}
}

Open in new window

0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Expert Comment

by:deepanjandas
ID: 35191326
sorry the code is:
function reverse() {
           if( txtObjectMC.currentFrame > 1 ){
        txtObjectMC.gotoAndStop( txtObjectMC.currentFrame - 1 );
        reverse();
   }
}

Open in new window

0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35191329
or try this:
function reverse() {
           if( txtObjectMC.currentFrame > 1 ){
        txtObjectMC.prevFrame();
        reverse();
   }
}

Open in new window

0
 
LVL 1

Expert Comment

by:smabudhahir
ID: 35191384
Hi deepanjandas, The time taken for every iteration while recursive call will not update the stage. So it will look like a jump to first frame. I think better way to use Enter_Frame event. Please correct me if i'm wrong.
0
 
LVL 17

Expert Comment

by:deepanjandas
ID: 35191415
Hmm..may smabudhahir is right.. ErnstJacobs you may use the ENTER_FRAME event to run the reverse functiion and clear it on the condition achieved.

Warm Regards
Deepanjan Das
0
 

Author Closing Comment

by:ErnstJacobs
ID: 35191761
I had to go for this code, it works perfectly :)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now