Solved

Flash - fade-out

Posted on 2011-03-22
9
348 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.

777 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