Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 3.0

Reply
 
Thread Tools Rate Thread Display Modes
Old 11-09-2009, 09:30 AM   #1
zombie_goasts
Registered User
 
Join Date: Oct 2009
Posts: 9
Default Button instance question

I've used the following code in order to achieve a menu function

Code:
MovieclipOne.addEventListener(MouseEvent.CLICK, initiateInstal);

function initiateInstal(evtObj:MouseEvent){
	trace ("The "+evtObj.target.name+" button was clicked!")
	gotoAndStop(evtObj.target.name);
}
For example, on the main timeline it looks like:

[MainPage][MovieclipOne][MovieclipTwo]

With the button's instance called "MoviceclipOne". But when I've clicked it, instead of getting the feedback of
Quote:
The MoviceclipOne button was clicked!
it gave me
Quote:
The instance57 button was clicked!
For the life of me I can't figure out if there are any other ways to change the instance for that button.

FYI, MoviceclipOne button is the instance of MoviceclipOne_bt.

Last edited by zombie_goasts; 11-09-2009 at 10:06 AM.
zombie_goasts is offline   Reply With Quote
Old 11-09-2009, 10:24 AM   #2
Tilpo
Watermelons are gansters
 
Tilpo's Avatar
 
Join Date: Aug 2008
Location: Hilversum, The Netherlands
Posts: 215
Default

You can do a second test to see what happens if you manually change the name property of that MovieClipOne instance.
ActionScript Code:
MovieClipOne.name = "MovieClipOne"; MovieclipOne.addEventListener(MouseEvent.CLICK, initiateInstal); function initiateInstal(evtObj:MouseEvent){     trace ("The "+evtObj.target.name+" button was clicked!")     gotoAndStop(evtObj.target.name); }
__________________

hoc postum continuit nudilo appendo
This post was touched by his noodly appendage.
Tilpo is offline   Reply With Quote
Old 11-09-2009, 10:34 AM   #3
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,684
Send a message via Skype™ to henke37
Default

This is something I explained in my recent article, stuff drawn in movieclips are not added in them directly, but as separate Shape instances. This combined with the event system leads to this issue. The solution is simple: if you want to know the deepest object clicked, use target, if you want the one with the listener, use currentTarget. For something else, start following parent references in a loop.
henke37 is offline   Reply With Quote
Old 11-09-2009, 11:15 AM   #4
raghu_thejus
Senior Member
 
Join Date: Apr 2009
Location: Chennai
Posts: 259
Thumbs up

Quote:
if you want to know the deepest object clicked, use target, if you want the one with the listener, use currentTarget.
can v use
Code:
MovieClipOne.mouseChildren=false
that wil not help!! henke???
__________________
Learn from your mistakes/fault.Never make any mistake/fault....
raghu_thejus is offline   Reply With Quote
Old 11-09-2009, 02:46 PM   #5
henke37
Senior Member
 
henke37's Avatar
 
Join Date: Mar 2009
Location: Sweden
Posts: 10,684
Send a message via Skype™ to henke37
Default

Of course, that is possible as well.
henke37 is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:36 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.