Link to home
Start Free TrialLog in
Avatar of junebm
junebm

asked on

How do I create a fade effect in Flash CS3 in one timeline?

Hi,
Here is what I am trying to do. My site is set up with product images with buttons that bring up a larger view of that particular product when the button is clicked. I have everything set up on one timeline, and would like to be able to click on my button and then when the larger image comes up along side of it it fades in. (The larger image/view fades into view.)
Below is an example of one of my pages. When you click on the smaller images it brings up a larger image in the box to the left of all of my buttons. Would love for the larger image to fade into view. Hope this question makes some sense. Also below is my code for one page. Would like to know where in the code I would add the effects.
thanks so much.
Picture-15.png
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Select the movie clip that contains your image and paste this actionscript into the Actions panel


onClipEvent (load) {
	var my_alpha:Number = 0;
	var inc_alpha:Number = 1;// this is the amount that the clips alpha (fade) will increase each time
	// and it is a combination of this value and the frame rate of your movie that will determin
	// how long it takes for your clip to fade up. For example, if the frame rate of your movie is 20 fps
	// then it will take five seconds (100% alpha / 20) = 5 seconds. Tinker with this number to get the effect you like
	this._alpha = my_alpha;
}
onClipEvent (enterFrame) {
	my_alpha = my_alpha + inc_alpha;
	if (my_alpha > 100) {
		my_alpha = 100;
	}
	this._alpha = my_alpha;	
}

Open in new window

Avatar of junebm
junebm

ASKER

Hi, thanks for the reply. I have a couple of other questions relating to this:

First, do I convert the images that I would like to add the effect to to "movie clip symbols" ?

Second, I currently have this set up so that when you click on a simple button it brings up the image as "frame number"...very simple.  Do I need to rewrite my code completely to get the effect I am wanting?  If you take a quick look at my current code you can see how simple it currently is.  

Can I add the fade effect under the "event handlers" for each frame?

I am kind of confused..... thanks for your help.
The easiest way to see how my code works is to do this.

1. start a new flash file so that you have an empty stage
2. Pop an image on the stage by either importing one or pasting one to the stage.
3. Select it with a single click
4. Press F8 and turn it into a movie clip.
5. Make sure it's still selected on the stage (click off it, then click it again if you're not sure or you can't  get this to work
6. goto the Actions panel. Make sure that 'script assist' is 'off' (button at the top right of the actions panel)
7. paste the code I gave earlier into the actions panel
8. Test the movie (control and enter)
9. You should see the clip smoothly fade up
Avatar of junebm

ASKER

Thanks so much...I can do that :)
Avatar of junebm

ASKER

Sorry,  I could not get this to work I think because I am using ActionScript 3.0, also keep getting error message that says there are too many characters in certain lines of the code.
ASKER CERTIFIED SOLUTION
Avatar of quizengine
quizengine
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of junebm

ASKER

ok, got that to work with on a practice file. Now, I have no idea how or where to put that code into my existing code, or if I need to rewrite the code I already have and incorporate this new stuff...??  As I have it now I just have simple buttons that pull up the image as frame number. For example: gotoAndStop(5); is this where I would put the new code in?
If you need me to send you my code again I will be very happy to do that.  Thanks for your help and patience. :)
Avatar of junebm

ASKER

Cannot find a way to make this code you gave me apply to what I am working on. It works great for single objects that don't interact with any buttons, which my project entails.
Let's say that you have an image on frame 5 that you want to fade up. Goto frame 5 on the timeline, and click the image. If it's already a movie clip (look in the properties panel) that's fine. If it isn't press F8 and give it a name. Make sure it's still selected, and paste the code I gave into the actions panel. Now when your movie gets to frame 5, that clip will play that code on itself to fade it up.

If it doesn't work because your movie is set to Actionscript 3, goto File, Publish settings and you can change that there to AS2.

If that disables existing code which needs AS3 then my solution isn't compatible with your movie and you would need to either a) rewrite your movie to work in AS2 or seek for another solution.