Solved

ActionScript 3: stage mouse out problem

Posted on 2010-11-16
5
636 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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 found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
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): …
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…

628 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