Solved

ActionScript 3: stage mouse out problem

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

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 my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
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.
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now