[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

flash fade photo in/out on mouseover

Posted on 2009-04-24
2
Medium Priority
?
444 Views
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) {
      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 !
0
Comment
Question by:Aleks
2 Comments
 
LVL 8

Accepted Solution

by:
Dreammonkey earned 1500 total points
ID: 24229382
1. try code below
2. ....
on (onRoll0ver) {
      this._alpha = 60;
}
on (onRollOut) {
      this._alpha = 100;
}

Open in new window

0
 
LVL 5

Expert Comment

by:john_hollings
ID: 24229627
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
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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. …
This article describes a solution to a problem of subloading one movie into another when they have different SWF versions. Sometime back, I was working on an ActionScript project while I came across an interesting fact which I would like to share…
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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.
Suggested Courses

834 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