Solved

Fade in/fade out button in flash

Posted on 2007-03-21
6
451 Views
Last Modified: 2010-04-03
I need a make an animated button in Flash that just fades in from alpha 0 to alpha 100 on rollover, and fades back out on rollout.  I would prefer to do it with AS, and have 'walked' through several tutorials on google, but I'm just not getting the jist of it...

(I have found some EE question/solutions on this, but the links to the solutions have expired or now broken, or refer to older versions, I am now using Flash 8, if that matters a whole lot)
0
Comment
Question by:cdr21
[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
  • 3
  • 3
6 Comments
 
LVL 5

Expert Comment

by:victmo
ID: 18767561
Hi cdr21,

You can do the following...

1.- Create a movieclip which is gonna be you button, it can contain an image or any graphic.
2.- Create a new layer inside your movieclip (this is where we're putting the code)
3.- Add the following actionscript in the first frame of the layer you just created:

tvar initAlpha = 50; //Chage to set the starting alpha value
var vel = 0.3; //Change to set the velocity of the fade in/out, Max value = 1

this.newAlpha=initAlpha;
this.onEnterFrame=function(){_alpha+=(newAlpha-_alpha)*vel;};
this.onRollOver=function(){newAlpha=100;};
this.onRollOut=this.onReleaseOutside=function(){na=0;};

Good Luck,

Vic
0
 

Author Comment

by:cdr21
ID: 18767760
Ok I did the following:

Inserted a new layer where the button needs to live on the main timeline
Drew a new rectangle to serve as the button; converted it to a MC, called it anim1
Double clicked in the new rectangle MC, to acces its timeline
Pasted your code in the first frame
Saved everything... tried the movie... just seeing a new blue rectangle I just drew, no animation :(

0
 
LVL 5

Accepted Solution

by:
victmo earned 500 total points
ID: 18768514
Hi Again,

Sorry, I had some finger problems...
on the first line its "var", not "tvar"...
on the last line its "newAlpha=0", not "na=0"...

Please try it and tell me if it works. The corrected code goes as follow:

var initAlpha = 50; //Chage to set the starting alpha value
var vel = 0.3; //Change to set the velocity of the fade in/out, Max value = 1

this.newAlpha=initAlpha;
this.onEnterFrame=function(){_alpha+=(newAlpha-_alpha)*vel;};
this.onRollOver=function(){newAlpha=100;};
this.onRollOut=this.onReleaseOutside=function(){newAlpha=0;};

Good luck,

Vic
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 

Author Comment

by:cdr21
ID: 18769046

Hey, Vic, that works!

Where should I put a geturl statement to make the button fully functional - in this case linking to an external url?
0
 

Author Comment

by:cdr21
ID: 18774473

Thanks for all your help Vic!

I got the geturl statement below to work, placing it just above your code

this.onRelease = function() {
 getURL("javascript:openFEP('ktre')");
 };
0
 
LVL 5

Expert Comment

by:victmo
ID: 18777874
Yeap, thats correct, you can place your code there or on the object:

on(release){
  //your code
}

Glad it worked,

Vic
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
IE 11 Flash Player issue 7 263
FLV versus SWF 11 295
camtasia alternative that can record 3 hours video plus audio 24 146
Adobe Flash Player - Active X vs NPAPI vs PPAPI 10 136
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

751 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