Link to home
Start Free TrialLog in
Avatar of Aleks
AleksFlag for United States of America

asked on

flash fade photo in/out on mouseover

I have a photograph that i turned into an object, it has an action to go to a link when clicked on, but i also want to add an action that will make it made out say 60% when the user gets the mouse over, when the mouse is moved elsewhere it should go back to its 100%.
This is the code I have on the photo right now (for the link).

on (press) {
      getURL("gallerynightshots.html");
}

What other code should I add to accomplish this ?
I am not too saavy in Flash, so step by step instructions are needd for this one.

Thanks in advance !

Thanks !
ASKER CERTIFIED SOLUTION
Avatar of Dreammonkey
Dreammonkey
Flag of Belgium 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
I assume you are using Actionscript2 and you are coding directly on the object (again I will assume this object is a MovieClip).  Firstly I would advise you to do all your coding on the main root timeline in a layer named actions.

Now in order to set the MovieClip up I would suggest have two layers named photograph, button.  In the bottom layer (photograph) you should have your graphic and in the top layer (button) you should have an invisible button.  

To create an invisible button, draw a rectangle over your graphic the same size, then with the rectangle selected only press F8 (windows).  This will open the symbol prompt.  Select button and give it a name 'mybtn' and click OK.  Now with this new symbol  created give it an instance name in the property panel, for this example I will be using mybtn_btn.

Again with mybtn_btn selected double click to edit in place.  You should see a timeline with four frame.  Within the timeline panel, click, hold and drag the keyframe to move it to the hit frame.  Now return your main root timeline.  Select your movieClip and give it an instance name in the property panel, again for this example 'mymc_mc'.

In your actions layer on the root timeline use the attached code.

I have also provided a very simple example please note you will need to rename the mybtnexample.txt to have the .fla extension.

This is a very basic fade for mouse over.  A more advanced way is using the Tween class, but the actionscript for this is a little more complicated but well worth looking into if you have time and are keen to learn.  If you need any further help let me know.

Hope this is of help.
// Create a fade effect 60%
// mymc_mc.mybtn_btn references the button within the movieclip
// onRollOver tells it to listen out from when the mouse moves over the button hit area.
mymc_mc.mybtn_btn.onRollOver = function() {
   //Here I am referencing only the moveclip and then setting the alpha to 60 percent.
   mymc_mc._alpha = 60;
}
 
//This next function listens out for when the mouse leaves the button hit area.
//When it does leave the hit area of the button it changes the alpha back to 100% 
mymc_mc.mybtn_btn.onRollOut = function() {
  //mymc_mc._alpha = 100;
}
 
//This function actions the onRelease, when the user clicks and releases the mouse button over the button hit area
//It will fire the getURL action.
mymc_mc.mybtn_btn.onRelease = function() {
  getURL("gallerynightshots.html");
}

Open in new window

mybuttonexample.txt