Solved

ActionScript 3: stage mouse out problem

Posted on 2010-11-16
5
634 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
[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
  • 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
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 record live broadcast.
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.

752 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