Advertisement

05.16.2008 at 10:09AM PDT, ID: 23409054
[x]
Attachment Details

Actionscript 3 mouse over problem when I move the mouse in and out very fast

Asked by ikjop in Macromedia Flash

Tags: adobe, flash, cs3

I made the following class that is used to display menu items. The class works but when I hover in and out of the "menu item" very fast the event handlers get "corrupted".

How do I solve this ?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
// MenuItems.as
 
package {
	
	import flash.display.Sprite;
	import flash.display.MovieClip;
	import flash.events.*;
	import fl.transitions.Tween;
	import fl.transitions.easing.*;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.text.TextFieldAutoSize;
	import flash.utils.Timer;
	import flash.media.Sound;
	import flash.net.URLRequest;
	
	public class MainMenuItem extends MovieClip {
		
		private var movMenuBox 		: MovieClip;
		private var txtfMenuFont 	: TextFormat;
		private var txtMenuText		: TextField;
		private var clrMenuColo		: uint;
		private var isGone			: Boolean;
		private var	twMenuTween		: Tween;
		private var sndMenuOverSound: Sound;
		
		public function MainMenuItem(menuLabel : String, menuColor : uint) : void {
			clrMenuColo = menuColor;
			constructItem(menuLabel);
			sndMenuOverSound = new Sound(new URLRequest("sounds/menubip.mp3"));
			
														
			
		}
		
		private function constructItem(menuLabel : String) : void {
			txtfMenuFont = new TextFormat();
			txtfMenuFont.font = new menuFont().fontName;
			txtfMenuFont.size = 8;
			txtfMenuFont.color = 0xffffff;
			
			txtMenuText = new TextField();
			txtMenuText.defaultTextFormat = txtfMenuFont;
			txtMenuText.embedFonts = true;
			txtMenuText.text = menuLabel;
			txtMenuText.autoSize = TextFieldAutoSize.LEFT;
			txtMenuText.selectable = false;
			txtMenuText.mouseEnabled = false;
			
			movMenuBox = new MovieClip();
			movMenuBox.graphics.beginFill(clrMenuColo);
			movMenuBox.graphics.drawRect(0,2, 200, 10);
			movMenuBox.graphics.endFill();
			movMenuBox.width = 200;
			movMenuBox.height = 20;
			
			addChild(movMenuBox);
			movMenuBox.addChild(txtMenuText);
			
			txtMenuText.addEventListener(MouseEvent.MOUSE_OVER, overMenuEvent);
			txtMenuText.addEventListener(MouseEvent.MOUSE_OUT, outMenuEvent);
			movMenuBox.addEventListener(MouseEvent.MOUSE_OVER, overMenuEvent);
			movMenuBox.addEventListener(MouseEvent.MOUSE_OUT, outMenuEvent);
			
		}
		
		private function overMenuEvent(e : MouseEvent):void{
			twMenuTween = new Tween(this,"alpha",Regular.easeIn,1,0.6,10);
			sndMenuOverSound.play();
		}
		
		private function outMenuEvent(e:MouseEvent):void{
			
			twMenuTween.yoyo();
			
		}
		
		
	}
}
[+][-]05.16.2008 at 11:21AM PDT, ID: 21585150

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 10:44AM PDT, ID: 21590190

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Macromedia Flash
Tags: adobe, flash, cs3
Sign Up Now!
Solution Provided By: ugeb
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.17.2008 at 01:00PM PDT, ID: 21590583

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628