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
Solved

ActionScript 3: stage mouse out problem

Posted on 2010-11-16
5
632 Views
Last Modified: 2013-11-11
I use the following ActionScript 3 functions to show and hide my controls:
public function showControlBar( e:MouseEvent )
		{
			if(controlBarStatus==1) return;
			else {
			 controlBarStatus=1;
			 myTween = new Tween( controlCont, "y", Regular.easeInOut, 25, 0, .7, true );
			 myTween.start();
			}
		}

		public function hideControlBar(e:MouseEvent)
		{
			if(controlBarStatus==0) return;
			controlBarStatus=0;
			controlCont.y=26;
		}

Open in new window


The controls should be shown when the cursor is over the movie and they should be hidden when the cursor is not over the movie.

I use this code to listen for the cursor position:
stage.addEventListener(MouseEvent.MOUSE_OVER,showControlBar);
stage.addEventListener(MouseEvent.MOUSE_OUT,hideControlBar);

Open in new window


The problem is that when I place my cursor over the controls, gets stuck in a loop of hiding the controls then showing them again.

I have attached the source code including the .swf, .fla and .as files.
MoviePlayer.zip
0
Comment
Question by:hankknight
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:moagrius
ID: 34149329
so you want it so that whenever the mouse is anywhere over the swiff itself, the control bar shows - but when it leaves the stage entirely (as would happen when embedded in an html document), the controls hide?
0
 
LVL 19

Accepted Solution

by:
moagrius earned 500 total points
ID: 34149448
assuming that's correct...


stage.addEventListener(MouseEvent.MOUSE_OVER,showControlBar);
stage.addEventListener(Event.MOUSE_LEAVE,hideControlBar);

// ...

public function showControlBar( e:MouseEvent )
{
	if(controlBarStatus==1) return;			
	 controlBarStatus=1;
	 new Tween( controlCont, "y", Regular.easeInOut, controlCont.y, 0, .7, true );			
}

public function hideControlBar(e:Event)
{
	if(controlBarStatus==0) return;
	controlBarStatus = 0;
	new Tween( controlCont, "y", Regular.easeInOut, controlCont.y, 25, .7, true );
}

Open in new window

0
 
LVL 16

Author Comment

by:hankknight
ID: 34150081
Thanks but your code does not help.  The problem remains.  You were right about what I am trying to accomplish.

If possible, could you please download the source code in the original post to see the problem?  Thanks!
0
 
LVL 19

Expert Comment

by:moagrius
ID: 34150242
i did - and i have a working version - make sure you "preview in html" as the mouse won't detect leaving the stage if just run via "test movie".

i'll upload the package.  you can just double-click the html file (before bothering with the FLA) to see it in operation. MoviePlayer-modified.zip
0
 
LVL 16

Author Closing Comment

by:hankknight
ID: 34150625
Thanks!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
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.

809 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