[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.6

Using addEventListener in ActionScript 3

Asked by rosedewar in ActionScript

Tags: ActionScript 3, AS3, Event Listener, addEventListener

Hello

I am struggling to make the transition from AS2 to AS3 and I need some help understanding how Flash AS3 handles mouse actions using the addEventListener.

I am authoring a simple Flash presentation which has a movie clip on the stage ('myMainMovieClip') and this contains a second movie clip ('myChildMovieClip').

In frame 1 of the main timeline (on the stage), I have two event listeners detecting MOUSE_OVER and MOUSE_OUT actions. (see code below).

When I test this, if the mouse cursor passes over myChildMovieClip which is inside myMainMovieClip, the parent movie clip then starts looping wildly.

This problem goes away when I change myChildMovieClip to a graphic instance instead of a movie clip instance. So why is this, and is there any way to have a movieclip within a movieclip and so it doesn't affect its parent when the addEventListener is used?

Can someone please explain to me what is going on here and why this happens?

Many thanks!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
function mainOver(myevent:MouseEvent):void {
        // Navigate to "Over" label of myMainMovieClip
	myMainMovieClip.gotoAndPlay("Over");
}
 
function mainOut(myevent:MouseEvent):void {
       // Navigate to "Out" label of myMainMovieClip
	myMainMovieClip.gotoAndPlay("Out");
}
 
myMainMovieClip.addEventListener(MouseEvent.MOUSE_OVER, mainOver);
myMainMovieClip.addEventListener(MouseEvent.MOUSE_OUT, mainOut);
 
Loading Advertisement...
 
[+][-]04/28/09 03:39 PM, ID: 24255880Accepted Solution

View this solution now by starting your 30-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: ActionScript
Tags: ActionScript 3, AS3, Event Listener, addEventListener
Sign Up Now!
Solution Provided By: john_hollings
Participating Experts: 2
Solution Grade: A
 
[+][-]04/28/09 03:39 PM, ID: 24255876Expert Comment

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 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93 - Hierarchy / EE_QW_3_20080625