Solved

How do I appear/dissapear a button on MOUSE EVENT?

Posted on 2010-08-27
6
311 Views
Last Modified: 2013-11-11
Hi all,

I'm trying to make my own flash player (not one of the packed ones gives me what I need) and I'm trying to make appear and dissapear the big middle "play/pause" button whn the user hovers the mouse. I've made a symbol (graphic) out of a JPG image and named it playBtn with Alpha = 0 (it will have auto play from the start) and solved all the AS3 errors in Flash CS5 but still the button don't appear (or dissapear if I start with Alpha = 100%).

Here's my code.

Any ideas?

Thanks in advance.
//Import for the Tween Class to fade controls out
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.MouseEvent;

var playBtn:Object = new Object();

playBtn.addEventListener(MouseEvent.MOUSE_OVER, showBtn);
playBtn.addEventListener(MouseEvent.MOUSE_OUT, dimBtn);

function showBtn(e:MouseEvent):void{
	playBtn.alpha = 1;
}

function dimBtn(e:MouseEvent):void{
	playBtn.alpha = 0;
}

Open in new window

0
Comment
Question by:Cesar Aracena
[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 39

Expert Comment

by:blue-genie
ID: 33540346
are your showBtn etc methods triggered?
why have you made it an Object ?

might be easier if you upload your file
0
 
LVL 6

Author Comment

by:Cesar Aracena
ID: 33540406
Dunno if the methods are triggered and I really don't know why an object... didn't know what else to decalre it. That might be the couse but I don't know what else to put in there.

I can't upload the file. It says that there's a file inside the .fla with the extension .xfl. Tried to compress it and got the same result.

How can I send it?

Thanks!!!!!
0
 
LVL 39

Expert Comment

by:blue-genie
ID: 33540776
put a trace inside your method


trace("show btn called");

check your output window - does it display the message when you mouseover the button?

i don't know about the xfl extension thing, try chaning your fla to filename.txt and upload that. (literally just change the extension)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Author Comment

by:Cesar Aracena
ID: 33541975
Thanks again blue-genie.

Tried tracing it but the output is white. Maybe I've put it wrong. Here's the file. It turns out that XFL extension is the new FLA extension for CS5. It's just a renamed ZIP containing an XML structure of the project (much like Flex). I guess EE guys will have to include it in the allowed extensions.

I saved it in CS4 FLA and now it's trully an encrypted file (like before).

BTW the middlePlayBtn (the one I'm trying to change on mouse event) has alpha 0. It's the layer 17.

Thanks again.
CUSTOM-BAR-PLAYER-CS4.fla
0
 
LVL 39

Accepted Solution

by:
blue-genie earned 250 total points
ID: 33548433
Hi again. when you compile the movie, ie. publish it - does it not give you an error?
you should have a compiler error tab which shows you issues and why you are not able to compile a file.

ok, step 1.
the graphic in the middle, change it to a movieclip, give it an instance name.
step 2
remove the var middlePlayBtn:Object = new Object line

your code should now work, ie. button not visible, rollover it the button is visible.

some quick FYI
if you have something on the stage and you want to be able to do something with it you must have it as a movieclip so that you can give it an instance name to reference it with.
if you place the thing on the stage directly you do not need to declare it in code, ie. var something:Something ... if you do it will throw an error.
if you are doing things with AS3 classes and you use addChild() to place it on the stage at runtime, then you would have to declare it.

hope that helps.
0
 
LVL 6

Author Closing Comment

by:Cesar Aracena
ID: 33562903
Sorry for the late response. I've got involved in other subject.

Great detailed explanation... worked like a charm ;)

Thanks!
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How  to reduce the .AVI file size of 90GB 4 381
how do I install adobe flash player on my ipad Air? 4 64
Adobe Indesign CS6 4 165
flash in chrome 4 141
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
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.

738 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