Advertisement

05.10.2008 at 06:56AM PDT, ID: 23391623
[x]
Attachment Details

Clicking on nested clips creates problems with the 'event.target' in the function calls

Asked by cursive in Macromedia Flash

Tags: actionscript 3.0

This is the structure of my nested clips

screen
   |
circle
   |
triangle

Visually, triangle is on top of circle, and circle is over the bottom part of screen


The screen calls a function when clicked, and the function uses event.target to obtain the id of the screen.

The problem is that if the user's mouse is over, say, triangle when he clicks, triangle will be passed as the event target instead of screen.

How do I do it so that no matter where on the screen the suer clicks, event.target will always be the users id?

Many thanks


 Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
for (var i:Number=0; i<4; i++) {
		var m=contents.addChild(new screen);		
                m.name="m"+i;
		m.myi=i;
                m.x=i*200
		m.buttonMode=true;
		m.addEventListener(MouseEvent.CLICK,jump);
}			
 
 
function jump(event:MouseEvent):void {
		var id=event.target.parent.myi;
		trace("event"+id)
}
Attachments:
 
Movieclip strcture
Movieclip strcture
 
 
 
[+][-]05.10.2008 at 07:31AM PDT, ID: 21539156

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: actionscript 3.0
Sign Up Now!
Solution Provided By: ddlam
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.10.2008 at 03:31PM PDT, ID: 21540766

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