gpt4 book ai didi

actionscript-3 - Actionscript 3,获取内部影片剪辑的实例名称

转载 作者:行者123 更新时间:2023-12-04 05:26:57 24 4
gpt4 key购买 nike

我正在尝试将对象放入将被 mask 的影片剪辑中
允许用户滚动浏览它们

我目前的解决方案是为每个事件添加事件监听器
内部影片剪辑...

outer_mc.myObject1.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject2.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject3.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject4.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject5.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject6.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject7.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject8.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject9.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject10.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject11.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);
outer_mc.myObject12.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);

function swapMovie(e:MouseEvent) {
trace(e.currentTarget.name + " selected");
}

由于可以有内部影片剪辑的可变列表,因此可以得到
不规则(和丑陋:) 所以我试图为父对象添加一个监听器
这是目前的尝试...
outer_mc.addEventListener(MouseEvent.MOUSE_DOWN, swapMovie);

function swapMovie(e:MouseEvent) {
trace(e.currentTarget.name + " selected");
}

然而,这只是返回“outer_mc”并使用 target 而不是 currentTarget
返回 Flash 分配给 instance128、instance 23 等的随机实例编号。

有没有人有一个解决方案可以获取子对象的实例名称
这将在 actionscript 3 中工作?我看过了,最接近的是使用
不返回实际实例名称的目标解决方案。

最佳答案

你可以尝试做这样的事情:

function swapMovie(e:MouseEvent) {
var current = e.target;
parent = current.parent;
while (parent != e.currentTarget)
{
current = current.parent;
parent = current.parent;
}

//Current should be your object, now
}

基本上它所做的是上升一级,直到它找到outer_mc,然后停止,并返回其点击的 child 。

关于actionscript-3 - Actionscript 3,获取内部影片剪辑的实例名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13089147/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com