Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Flash - fade-out

Posted on 2011-03-22
9
Medium Priority
?
372 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 1

Accepted Solution

by:
smabudhahir earned 1000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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…
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 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…
Suggested Courses

647 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