首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >访问目标之前的MovieClip

访问目标之前的MovieClip
EN

Stack Overflow用户
提问于 2013-01-13 06:04:58
回答 1查看 67关注 0票数 0

我是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--我认为使用它时也会出错。

EN

回答 1

Stack Overflow用户

发布于 2013-01-13 06:29:57

您可以使用目标上的“父”属性来获取它的父对象,假设目标是DisplayObject类型的对象(在本例中是这样)。

代码语言:javascript
复制
// 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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14301107

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档