flash fade photo in/out on mouseover

Posted on 2009-04-24
Last Modified: 2012-08-13
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) {

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 !
Question by:amucinobluedot
    LVL 8

    Accepted Solution

    1. try code below
    2. ....
    on (onRoll0ver) {
          this._alpha = 60;
    on (onRollOut) {
          this._alpha = 100;

    Open in new window

    LVL 5

    Expert Comment

    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() {

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
    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. …
    In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

    737 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

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now