Zinferno Oak
Zinferno Oak

Reputation: 1

Accessing to the MovieClip before the target

I'm very new in AS3 programming,

Problem Example

onStage I have image_contenter as MovieClip.

image_contenter_mc ----Stage

movieClip1 ----Inside image_contenter_mc

movieClip2 ----Inside movieClip1

movieClip3 ----Inside movieClip2

movieClip4 ----Inside movieClip3

now I try to access to the movieClip3 by using

event.target.name

it return movieClip4 and

event.currentTarget

also not work. So how can I access the movieClip3 and movieClip2

event.(target-1).name --i think it will error when i use this also.

Upvotes: 0

Views: 68

Answers (1)

mitim
mitim

Reputation: 3201

you can use the "parent" property on the target to get its parent, assuming the target is a DisplayObject type of object (which in this case it is).

// cast the target to a DisplayObject (since we want to treat it as a DisplayObject object)
var current:DisplayObject = (DisplayObject) (event.target);

// this would lead to the parent of the display object
// movieclip 3 is the parent of movieclip 4
// movieclip 2 is the parent of movieclip 3
// and so on
trace(current.parent);

DisplayObject - Adobe ActionScript® 3 (AS3 ) API Reference http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#parent

Upvotes: 1

Related Questions