Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ActionScript 3: stage mouse out problem

Posted on 2010-11-16
5
Medium Priority
?
640 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 2000 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
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,…
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): …
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.

972 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