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

Fade up/out MovieClip

Contributor ,
Jul 01, 2024 Jul 01, 2024

Copy link to clipboard

Copied

I have a simple scene with multiple buttons that each start a different video. Each video lives on a separate frame. Click a button, and it goes to the salient frame and the video plays. What I'd like to do is have the video fade up, play, then fade out. I don't know how to do this. Each button click goes to the frame where it's video lives. 

 

The first frame has all of the actions. They take the following form:

 

this.scarcity_btn.addEventListener("click", fl_ClickToGoToAndStopAtFrame_6.bind(this));
function fl_ClickToGoToAndStopAtFrame_6()
{
this.gotoAndStop(5);
}
 
At each frame where a particular video lives, there's:
this.stop();
 
Since mp4's dont' support alpha channels, I can't do the fading in/out in the video file itself. 
 
Any help would be appreciated.

Views

892

Translate

Translate

Report

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

Community Expert , Jul 02, 2024 Jul 02, 2024

Hi.

 

Video components wrap DOM elements, so you'll need CSS for it.

 

You can add the styles in the HTML file using a publish template or use the .animate method in JavaScript, for example.

var root = this;

// the two methods below could live in the first frame
root.onDrawEnd = function(e, data)
{
    root.fadeVideo(data.id, data.from, data.to, data.duration);
};

root.fadeVideo = function(id, from, to, duration)
{
    currentVideo = document.getElementById(id);
    currentVideo.animate([{ opa
...

Votes

Translate

Translate
Contributor ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

Well, I added the below and still no joy. Once the button is pushed and the video runs its course, upon the next button push it fades up over 2 seconds then disappears, or I'm presuming the opacity goes to 0.

 

if(!this.alreadyExecuted){
this.lead_btn.addEventListener("click", fl_ClickToGoToAndStopAtFrame_2.bind(this));
function fl_ClickToGoToAndStopAtFrame_2()
{
this.gotoAndStop(0);
}
this.alreadyExecuted=true;
}

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

not the function, too.

 

upload you fla, post link.

Votes

Translate

Translate

Report

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

which of the 3 flas is the current fla?

Votes

Translate

Translate

Report

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

Oh sorry about that. It's ogl_interactive_v01_wip02.fla

--
Michael J. Narlock

Votes

Translate

Translate

Report

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

It's ogl_interactive_v01_wip02.fla.

Votes

Translate

Translate

Report

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 ,
Jul 11, 2024 Jul 11, 2024

Copy link to clipboard

Copied

I tried a method to omit the function, as seen below, and that too didn't work. 

if(!this.alreadyExecuted){
this.lead_btn.addEventListener("click", fl_ClickToGoToAndStopAtFrame_2.bind(this));
 
this.alreadyExecuted=true;
}
 
function fl_ClickToGoToAndStopAtFrame_2()
{
this.gotoAndStop(0);
}

Votes

Translate

Translate

Report

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 ,
Jul 12, 2024 Jul 12, 2024

Copy link to clipboard

Copied

Thank you both for your patience in helping me figure this out. I think I'm on the right path to redo the way I had done my previous layout, but I'm still struggling with one important aspect. Once I've clicked a button and the video has run it's course, the next time I click the button (any button really since I'm using the same video component and just changing the source), the video fades up and then disappears immediately. I know what's causing it because if I set the opacities in the e.currentTarget.animate from 1 to 1 (to: to to: in the parlance of the code) the video is replayable...it fades up, it just never fades down. I'm struggling to understand why the video can't fade down and the function bring it back upon button repress.

 

My suspicion is that the function thinks the video has "ended" already and just changes the opacity to 0 after duration. Is there a clever way to reset that? Perhaps this isn't what's going on...just a guess, really.

 

The code is below:

var root = this;
 
root.onDrawEnd = function(e, data)
{
    root.fadeVideo(data.id, data.from, data.to, data.duration);
};
 
root.fadeVideo = function(id, from, to, duration)
{
    currentVideo = document.getElementById(id);
currentVideo.animate([{ opacity: from }, { opacity: to }], { duration: duration });
    currentVideo.addEventListener("ended", function(e)
    {
        e.currentTarget.animate([{ opacity: to }, { opacity: from }], { duration: duration, fill: "forwards" });
    });
 
};
 
function changeVideoSource() 
stage.on("drawend", root.onDrawEnd, null, true, { id: "yourVideo", from: 0, to: 1, duration: 2000 });
document.getElementById("yourVideo").src="../videos/HABs_eng.mp4"; 
 
this.yourButton.on("click", changeVideoSource);
 
function changeVideoSource2() 
stage.on("drawend", root.onDrawEnd, null, true, { id: "yourVideo", from: 0, to: 1, duration: 2000 });
document.getElementById("yourVideo").src="../videos/Lead_esp.mp4"; } 
 
this.yourButton2.on("click", changeVideoSource2);
 

 

Votes

Translate

Translate

Report

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 ,
Jul 15, 2024 Jul 15, 2024

Copy link to clipboard

Copied

LATEST

For posterity, I figured out the issue as seen below:

 

root.fadeVideo = function(id, from, to, duration)
{
    currentVideo = document.getElementById(id);
currentVideo.animate([{ opacity: from }, { opacity: to }], { duration: duration, fill: "forwards" });
    currentVideo.addEventListener("ended", function(e)
    {
        e.currentTarget.animate([{ opacity: to }, { opacity: from }], { duration: duration, fill: "forwards" });
    });

Votes

Translate

Translate

Report

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 ,
Jul 02, 2024 Jul 02, 2024

Copy link to clipboard

Copied

Thank you to you both! I'll give this a shot. 

Votes

Translate

Translate

Report

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
Community Expert ,
Jul 02, 2024 Jul 02, 2024

Copy link to clipboard

Copied

thumbs up 

Votes

Translate

Translate

Report

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