all groups > flash (macromedia) > may 2007 >
You're in the

flash (macromedia)

group:

Fading movie out once it is finished


Re: Fading movie out once it is finished David Stiller
5/29/2007 4:00:07 PM
flash (macromedia):
mb8276

[quoted text, click to view]

Are you talking about a movie clip inside a Flash movie (a SWF)? If so,
you could either tween that movie clip by hand in the timeline or use
ActionScript to fade it out.

[quoted text, click to view]

What version of ActionScript are you aiming for?


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: Fading movie out once it is finished David Stiller
5/29/2007 4:34:37 PM
mb8276,

[quoted text, click to view]

2.0, then. There are two goals, here: a) figure out when the end of
the movie is (or do you mean the end of the movie clip?) and b) animate a
progressive reduction in alpha over time.

The main timeline is a movie clip, just like any movie clip symbol, so
you can reference MovieClip class members against it. What are "class
members"? Good question, and the answer is pretty helpful. In
ActionScript, just about everything can be described in terms of an object,
and classes define those objects. The "MovieClip class" describes the
functionality available to all movie clip, the "TextField class" handles
dynamic and input text fields, the "Sound class" handles sounds, and so on.
Class entries, in the ActionScript 2.0 Language Reference, general feature
up to three categories: properties (charactersistics the object has),
methods (things the object can do), and events (things the object can react
to). So in a sense, they make great little "Owner's Manuals" for the object
in question.

In your case, if you want to fade out the movie clip when the main
timeline ends, you could *check* for an ending via ActionScript, but the
easiest approach would simply be to put your fade-out code on a keyframe
near the end of the main timeline. -- In which case, you might just be able
to use a tween to fade out that clip's Alpha property (see the Properties
inspector for that movie clip).

If you're checking on the end of the movie clip, make sure it has an
instance name (again, see the Properties inspector). Once that clip has a
name, you can reference it via ActionScript and apply MovieClip class
members to it. Assuming an instance name myClip, for example:

myClip._x = 500;

.... that would set the clip's horizontal position to 500 pixels in from the
left side of its parent (perhaps the Stage). You'll see the MovieClip._x
property in the MovieClip class entry of the documentation.

If you want to repeatedly check to see if the clip has finished playing
.... you could assign a function to its MovieClip.onEnterFrame event:

myClip.onEnterFrame = function():Void {
if (this._currentframe == this._totalframes) {
trace("done");
}
}

Again, you'll see the _currentframe and _totalframes properties in the
MovieClip class entry. They're characteristics of the object, so they're in
the Properties heading. Meanwhile, onEnterFrame is an event -- the movie
clip can react to each occurence of its entering a frame.

The if() statement lets you compare values. If the current frame is
equal to the last frame, badda boom. At that point, you can re-assign that
onEnterFrame handler to fade out the clip's _alpha as it enters each frame.
Finally, when _alpha is zero, you'd kill the event handler:

myClip.onEnterFrame = function():Void {
if (this._currentframe == this._totalframes) {
this.onEnterFrame = function():Void {
if (this._alpha > 0) {
this._alpha -= 10;
} else {
this._alpha = 0;
delete this.onEnterFrame;
}
};
}
};



David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Fading movie out once it is finished mb8276
5/29/2007 7:52:49 PM
Hi Everyone,
I would like to know if anyone knows how to fade a movie embedded in a Flash
file to fade out when it's finished playing?
I'm not that great with scripting, and I tried to see if I could do it, but
the action scripting has changed so much.
Please help!
Thank you in advance.
Re: Fading movie out once it is finished mb8276
5/29/2007 8:16:16 PM
Re: Fading movie out once it is finished Boysen Payne
5/29/2007 8:29:06 PM
You're looking to use some actionscript. An event handler triggered to "fade
out" the clip once the Trailer is finished loading, like:
trailer_ldr.addEventListener(Event.COMPLETE, completed);

where completed is a function that sets either an onEnterFrame Event or timer
to drop the alpha in an incremented fashion until its 0.

Hope that helps...

Boysenberry Payne

Re: Fading movie out once it is finished Boysen Payne
5/29/2007 8:30:21 PM
Re: Fading movie out once it is finished mb8276
5/29/2007 9:05:09 PM
Thank you so much everyone.
I took the trailer and changed it to a movie clip instead of a graphic now.
Plus I gave it a name to reference it in the script. I understand maybe half of
what David said about this.
And I tried some of the scripting you provided, but I get errors and it
doesn't work right. I think it's because I have a "stop" in the script.
I have the "stop" in the script for the timeline to stop and let the movie
clip run. So, now I'm working on trying to make the movie clip fade out when
it's completed, is this right?
Is having the "stop" okay?
Re: Fading movie out once it is finished David Stiller
5/29/2007 10:49:24 PM
mb8276,

[quoted text, click to view]

Graphics have timelines, just like movie clips do, but movie clip
timelines aren't locked in-step with the timelines of their parents. That
may or may not make a difference to you, but in ActionScript 2.0, you can't
program graphic symbols.

[quoted text, click to view]

If I can, I'll be happy to clarify. :)

[quoted text, click to view]

What errors to you get? What isn't working?

[quoted text, click to view]

That sounds right to me. When I was working out my reply, I had a movie
clip with 30 frames in its own timeline, set in frame 1 of the main
timeline. I could have set that movie clip in frame 10 of the main
timeline, or frame 50, or 100 -- makes no difference. Whatever frame (in
the main timeline) needs to stop, that's what frame you'd put your stop()
in. Then, in that same frame, you could use the code (or similar code) to
the suggestion I made earlier.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: Fading movie out once it is finished David Stiller
5/30/2007 9:42:04 AM
mb8276,

[quoted text, click to view]

This is why I asked what version of the language you were using. ;)
That error tells me your publish settings are configured for ActionScript
3.0. Head over to File > Publish Settings, Flash tab, and set your version
of ActionScript to 2.0.

Give that a whirl and come back if you still have questions.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: Fading movie out once it is finished David Stiller
5/30/2007 11:03:37 AM
mb8276,

[quoted text, click to view]

There's an AS2 version of the FLVPlayback Component in the Components
panel. When you switch back and forth between the two languages, you'll see
the total assortment of Components change.


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."

Re: Fading movie out once it is finished mb8276
5/30/2007 1:10:41 PM
Here are the errors I get:
1046: Type was not found or was not a complie-time constant: Void.
This repeats another two times and gives these sources:
gringo.onEnterFrame = function():Void {
gringo.onEnterFrame = function():Void {
this.onEnterFrame = function():Void {

This is what I have on the frame that has the movie clip:
stop();
gringo.onEnterFrame = function():Void {
if (this._currentframe == this._totalframes) {
trace("done");
}
}


gringo.onEnterFrame = function():Void {
if (this._currentframe == this._totalframes) {
this.onEnterFrame = function():Void {
if (this._alpha > 0) {
this._alpha -= 10;
} else {
this._alpha = 0;
delete this.onEnterFrame;
}
};
}
};

Is it something with the function?
Re: Fading movie out once it is finished mb8276
5/30/2007 2:17:54 PM
Now, I have the error:
WARNING: The component 'fl.video.FLVPlayback' requires ActionScript 3.0.

The movie trailer was brought into Flash and saved out as a Flash video file.

I went
herehttp://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.h
tm?context=LiveDocs_Parts&file=00000955.html to use this code:
gringo.onEnterFrame = function() {
gringo._alpha -= 5;
if (gringo._alpha <= 0) {
gringo._visible = false;
delete gringo.onEnterFrame;
}
};

I changed my publish settings to 2.0, but since it's a flash video file, it's
requesting 3.0 :(
Re: Fading movie out once it is finished mb8276
5/30/2007 2:55:42 PM
I got it working!
I just had to keep adjusting the frames value from 1200 to 1460 in the 3.0 code.
Re: Fading movie out once it is finished mb8276
5/30/2007 3:16:07 PM
Oh good. I'll definitely look at that the next time.
AddThis Social Bookmark Button