Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Fade Between to frames?

New Here ,
Feb 02, 2011 Feb 02, 2011

Hey Guys,

im really a nab to Flash, just started. Well, i have a question - please describe in your answers what you do.

How can i with ActionScript 3.0, make a black fade when changin from frame 1 to frame 2. So its kinda, fades out when i click button, and fades in with new window?

Thanks.

TOPICS
ActionScript
6.7K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Feb 02, 2011 Feb 02, 2011

You can't do anything between adjacent frames.  If you want something to fade in one frame using actionscript, you either tween its alpha property from 1 to 0, or you tween the alpha property of something that covers it from 0 to 1 (in your case something black covers it).

So what I do is I look up the Tween class in the help documents to see what parameters I need to specify in creating a new Tween instance and then code that according to what I know I want (I'll actually usually just copy an ex

...
Translate
Contributor ,
Feb 02, 2011 Feb 02, 2011

It takes more than two frames to create a "Fade" effect.

Fade usually means that it will gradually change.  How long you want the Fade effect to last will tell you how many frames you will need. 

For example, by using 24 fps setting, you will need 24 frames for the Fade effect to last 1 second, 48 frames to have it last 2 seconds.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 02, 2011 Feb 02, 2011

You can't do anything between adjacent frames.  If you want something to fade in one frame using actionscript, you either tween its alpha property from 1 to 0, or you tween the alpha property of something that covers it from 0 to 1 (in your case something black covers it).

So what I do is I look up the Tween class in the help documents to see what parameters I need to specify in creating a new Tween instance and then code that according to what I know I want (I'll actually usually just copy an existing one and convert it to my needs).

Here's some code that fades in an object with an instance name of blackThing in 2 seconds...

import fl.transitions.Tween;
import fl.transitions.easing.*;

var twAlpha:Tween = new Tween(blackThing, "alpha", Regular.easeIn, 0,  1, 2, true);

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 02, 2011 Feb 02, 2011

Ned! That was almost what i were looking for!

Is there a way that i can make:

var twAlpha:Tween = new Tween(blackThing, "alpha", Regular.easeIn, 0,  1, 2, true);

Work with frames also? So its "fading in" the entire frame, and not just an object?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Feb 02, 2011 Feb 02, 2011

A frame is not an object, you fade the object, not the frame.


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 02, 2011 Feb 02, 2011

No, frames are pretty much just places to hold things. It's the things that you control with the code, or movement along the timeline, but a frame is not an object that you can manipulate with code.  You would need to convert all that is in that frame into an object (movieclip) and use code to fade the whole thing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Feb 02, 2011 Feb 02, 2011

If you are using the time line to place your code,

what you are able to do is create a sprite/movieClip and place it on a new layer above your current layers.  Then give that movieClip a instance name.

Say fade_mc

Then turn that clip .alpha=0

on frame 1 through the code fade_mc.alpha=0

now you said if you click a button it will fade then go to frame two.

so on click of the next button, do not have the frame move from 1 - 2 .. have fade_mc tween from its alpha to a solid state vaie use of theTween class

var myTween:Tween = new Tween(fade_mc, "alpha", Strong.easeOut, 0, 100, 1, true);

next_btn.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent){
myTween.start();
}

This is the Tween engine of AS3 in the future you may learn of other tweens.  I use GreenSock which is a great tweening engine.

Now this will cause your fade_clip to fade up at 1 second.

now if we listen to the fade complete we can move the time line to frame_2

myTween.addEventListener(TweenEvent.MOTION_FINISH, fadeUpComplete);

function fadeUpComplete(te:TweenEvent):void{

       this.nextFrame()

     fadeDown()

}

function fadeDown(){

var myTween:Tween = new Tween(fade_mc, "alpha", Strong.easeOut, 100, 0, 1, true);

}

Now the last line will fade your clip back to 0 revealing the contents of frame 2.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 14, 2013 Aug 14, 2013
LATEST

I just created a rep on GitHub that does exactly what you're asking:

https://github.com/Abrahamh08/Frame-Transitions-AS3

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines