我是AS3编程的新手,
onStage我将image_contenter作为MovieClip。
image_contenter_mc ----舞台
movieClip1 ----里面的image_contenter_mc
movieClip2 ----在movieClip1内部
movieClip3 ----在movieClip2内部
movieClip4 ----在movieClip3内部
现在我尝试使用
访问movieClip3event.target.name
它返回movieClip4和
event.currentTarget
也行不通。那么如何访问movieClip3和movieClip2
event。(target-1).name - 我认为当我也使用它时会出错。
答案 0 :(得分:1)
您可以使用目标上的“parent”属性来获取其父级,假设目标是DisplayObject类型的对象(在这种情况下它是)。
// 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 - AdobeActionScript®3(AS3)API参考 http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#parent