Solved

Flash - fade-out

Posted on 2011-03-22
9
331 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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
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 goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

746 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

12 Experts available now in Live!

Get 1:1 Help Now