博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
一个另类的swapChildren的实现
阅读量:4079 次
发布时间:2019-05-25

本文共 2227 字,大约阅读时间需要 7 分钟。

一个另类的swapChildren的实现

 

I’m working on a project right now and swapChildren is just not working as expected. 

Looked around a bit, and I just decided to remove the two children and add copies of them instead:

var tmpThis:Canvas= EV.target as Canvas;
var tmpHighest:Canvas= highestPanel;
removeChild (highestPanel);
removeChild (EV.target as Canvas);
addChild(tmpHighest);
addChild(tmpThis);
 
------------------------------------------------------------------------------------------
 
 

原文出處:

在flex2中, 一個容器的子控制項相互重疊(如Canvas), 由z-order決定. swapChildren, swapChildrenAt用來交換兩個子控制項的z-order, 但有時會拋如下異常:

1 can1.swapChildrenAt(1, 0);

RangeError: Error #2006: The supplied index is out of bounds.

1 can1.swapChildren(clus1, t1);

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.

我碰到這種異常的典型情況是當子控制項Resize到超出Canvas之外時. 不過可以用如下兩種方式替代實現控制z-order:

1). Put child1 at the most z-order:

1 container.removeChild(child1);
2 container.addChild(child1);

利用了每次添加的child總具有最大的z-order.

2). swap two children child1 and child2:

1 var i1:int = container.getChildIndex(child1);
2 var i2:int = container.getChildIndex(child2);
3 container.setChildIndex(child1, i2);
4 container.setChildIndex(child2, i1);

具體原因描述可在一個mail list找到: (http://www.mail-archive.com/flexcoders@yahoogroups.com/msg61112.html):

“You say your container is a DisplayObjectContainer. Is it also a Flex Container
such as Canvas or VBox? If so, there is a bug with using swapChildrenAt() and
maybe with swapChildren() as well. Try using removeChildAt() and addChildAt()
instead.

A Flex Container does tricky stuff with child indexes and overrides child

management APIs such as numChildren, addChildAt(), removeChildAt(), etc.,
because there are two kinds of children — content children and non-content
children. If you write

1 <HBox>
2     <Button/>
3     <Button/>
4 </HBox>

there are only two content children but, if the HBox has a background or

scrollbars, there can be additional non-children children.

I think what happened is that the swapChildren() and swapChildrenAt() methods

got added to DisplayObjectContainer in Player 9, and the Flex framework is not
yet supporting them properly in the Container class.

- Gordon”

posted on 2010-04-29 10:03 阅读(...) 评论(...)

转载地址:http://xhpni.baihongyu.com/

你可能感兴趣的文章
也有用LQR对四轴飞行器控制的
查看>>
四轴的控制方法和平衡车的控制方法都可以归结为欠驱动系统的控制方法,这才是玩通了。
查看>>
欠驱动系统的控制是非线性控制理论中最具挑战性的方向之一
查看>>
这篇学位论文对欠驱动系统说得不错《欠驱动非线性系统控制问题的研究》
查看>>
我感觉论文写不了创新性的写个综述也可以啊,就总结概括前人的。
查看>>
原来惯性飞轮最开始是用在卫星姿态的调整里面的
查看>>
滑模控制我看在欠驱动系统的控制里面也出现得挺多
查看>>
这样的也可以发.....
查看>>
滑模控制基本概念
查看>>
我感觉真正的关键是你做出东西,做出成果,在这个互联网时代不会埋没你,
查看>>
无名的ADRC的具体方案
查看>>
我的F330 ACfly动力配置
查看>>
无名的飞控默认是用的PID,没用ADRC,可以改变宏定义切换。而且只在角速度环用ADRC。
查看>>
我发现《四轴飞行器DIY-基于STM32微控制器》,还有crazypony,还有无名,匿名这类没有用操作系统的都是靠定时器中断来弄的。
查看>>
弄清楚这里所说的解耦是什么意思。
查看>>
我准备把ACfly和T265接上
查看>>
T265源码下载及案例实验(这个人运行成功了realsense里的pose例程,获得位置数据!)
查看>>
网上搜到的树莓派使用串口(uart或者USB)都是Python来用的,我感觉我得换成x86系统来弄或许好些。
查看>>
Mavlink协议是在串口通讯基础上的一种更高层的开源通讯协议,似乎校验更多比串口更可靠?
查看>>
移植mavlink到stm32详细教程,后面附快速移植方法
查看>>