当前位置: 首页 > news >正文

flex z-order错误解决

在flex3中, 一个容器的子控件相互重叠(如Canvas), 由z-order决定. swapChildren, swapChildrenAt用来交换两个子控件的z-order, 但有时会抛如下异常:

can1.swapChildrenAt(1, 0);
RangeError: Error #2006: The supplied index is out of bounds.

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:
container.removeChild(child1);
container.addChild(child1);
利用了每次添加的child总具有最大的z-order.

2). swap two children child1 and child2:
var i1:int = container.getChildIndex(child1);
var i2:int = container.getChildIndex(child2);
container.setChildIndex(child1, i2);
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
 
<HBox>
    <Button/>
    <Button/>
</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"

顺便提一下:
1). PopUpManager也可改变重叠状态, 但它是作为弹出窗口, 改变了原先的层次(父子)关系, 所在坐标轴等.
2). debug模式下用trace(string)可在控制台打印调试信息.
3). Canvas有个clipContent可允许子控件显示超出Canvas的范围(http://www.judahfrangipane.com/blog/?p=101).
4). horizontalScrollPolicy="off" verticalScrollPolicy="off"可以去掉滚动条.

 

相关文章:

  • css居中小结
  • Flex的DataGrid中时间如何格式化
  • 买卖股票最佳时机
  • parentApplication 和parentDocument 的区别
  • C#设计模式(11)——外观模式
  • flex大小写转化
  • Target runtime Apache Tomcat 5.5 is not defined
  • Android耗时操作
  • hibernate自定义主键
  • 2017.3.9 组合数学学习——组合、多重集排列
  • Flex:PopUpManager的createPopUp与addPopUp区别
  • HTTP协议返回状态码
  • sql之左连接、右连接、全连接
  • c#元组举例
  • RSA证书说明
  • 4. 路由到控制器 - Laravel从零开始教程
  • Android 控件背景颜色处理
  • emacs初体验
  • Fastjson的基本使用方法大全
  • Javascript编码规范
  • k8s如何管理Pod
  • Node 版本管理
  • Object.assign方法不能实现深复制
  • React Native移动开发实战-3-实现页面间的数据传递
  • scrapy学习之路4(itemloder的使用)
  • yii2中session跨域名的问题
  • 基于遗传算法的优化问题求解
  • 使用 Node.js 的 nodemailer 模块发送邮件(支持 QQ、163 等、支持附件)
  • 【云吞铺子】性能抖动剖析(二)
  • 积累各种好的链接
  • 如何正确理解,内页权重高于首页?
  • ​Spring Boot 分片上传文件
  • ​创新驱动,边缘计算领袖:亚马逊云科技海外服务器服务再进化
  • # Pytorch 中可以直接调用的Loss Functions总结:
  • (11)工业界推荐系统-小红书推荐场景及内部实践【粗排三塔模型】
  • (9)STL算法之逆转旋转
  • (java版)排序算法----【冒泡,选择,插入,希尔,快速排序,归并排序,基数排序】超详细~~
  • (js)循环条件满足时终止循环
  • (Matalb回归预测)PSO-BP粒子群算法优化BP神经网络的多维回归预测
  • (pt可视化)利用torch的make_grid进行张量可视化
  • (Pytorch框架)神经网络输出维度调试,做出我们自己的网络来!!(详细教程~)
  • (第27天)Oracle 数据泵转换分区表
  • (顶刊)一个基于分类代理模型的超多目标优化算法
  • (二)WCF的Binding模型
  • (附源码)spring boot建达集团公司平台 毕业设计 141538
  • (区间dp) (经典例题) 石子合并
  • (轉貼) 資訊相關科系畢業的學生,未來會是什麼樣子?(Misc)
  • .[hudsonL@cock.li].mkp勒索病毒数据怎么处理|数据解密恢复
  • .bat批处理(三):变量声明、设置、拼接、截取
  • .bat批处理(十):从路径字符串中截取盘符、文件名、后缀名等信息
  • .NET HttpWebRequest、WebClient、HttpClient
  • .NET 设计模式—适配器模式(Adapter Pattern)
  • .NET/ASP.NETMVC 大型站点架构设计—迁移Model元数据设置项(自定义元数据提供程序)...
  • .NET:自动将请求参数绑定到ASPX、ASHX和MVC(菜鸟必看)
  • .net打印*三角形