我是AS3编程的新手,
问题实例
onStage我让image_contenter当MovieClip。
image_contenter_mc .阶段 movieClip1 - image_contenter_mc内部 movieClip2 - movieClip1内部 movieClip3 - movieClip2内部 movieClip4 - movieClip3内部
现在,我尝试通过以下方法访问movieClip3
event.target.name
它返回movieClip4和
event.currentTarget
也不起作用。那么我如何访问movieClip3和movieClip2呢?
事件。(目标-1).name--我认为使用它时也会出错。
发布于 2013-01-13 06:29:57
您可以使用目标上的“父”属性来获取它的父对象,假设目标是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 -ActionScript 3 (AS3 ) API引用US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#parent
https://stackoverflow.com/questions/14301107
复制相似问题