动作3:(?)的UIScrollBar错误 - 宽度集装箱返回+ 85px的 [英] ActionScript 3: UIScrollBar bug(?) - width of container returns +85px

查看:216
本文介绍了动作3:(?)的UIScrollBar错误 - 宽度集装箱返回+ 85px的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Flash CS5我碰到一些奇怪今天来了。

Using Flash CS5 I came across something odd today.

将UIScrollBar组件具有刚性宽度均为15px的。当你将它添加到一个容器,如雪碧,你所期望的精灵回到15的宽度,但它返回100,而不是!

The UIScrollBar component has the rigid width of 15px. When you add it to a container such as a Sprite, you'd expect the width of the sprite to return 15, but it returns 100 instead!

下面是一个例子code。

Here's an example code.

import flash.display.Sprite;
import fl.controls.UIScrollBar;

var spr:Sprite = new Sprite();
addChild(spr);
trace('spr.width:',spr.width);

var bar:UIScrollBar = new UIScrollBar();
spr.addChild(bar);
trace('bar.width',bar.width);
trace('spr.width:',spr.width);

有趣的是,输出

Interestingly, output is

spr.width:0
  bar.width 15
  spr.width:100

spr.width: 0
bar.width 15
spr.width: 100

有谁知道发生了什么呢?这是一个错误?

Does anybody know what's happening there? Is this a bug?

推荐答案

发现,这是一种错误的。什么情况是,它需要一些时间,它绘制/呈现在舞台上的组件,因此它的大小可以访问时它绘制之后。根据记录,在我的电脑需要1毫秒。直到返回的预期值。

Found out that it's kind of a bug. What happens is, it takes some time for it to draw/render the component on the stage so its size becomes accessible only after it's drawn. For the record, in my computer it takes 1 ms. until it returns the expected value.

另一个奇怪的问题是,的UIScrollBar返回15px的是它的宽度,而容器精灵收益16像素。对于那些寻找原因,它可能涉及到的酒吧,这是绘制厚度= 1 的scaleMode = LineScaleMode.NONE <纲要/ code>。我有一类我写的,其中我已经加1到每个超级方法的返回值来覆盖的宽度和高度getter方法​​有相同的问题。

Another surprising issue is, UIScrollBar returns 15px as its width whereas the container sprite returns 16px. For those looking for the reason, it's probably related to the outline of the bar, which is drawn with thickness=1 and scaleMode=LineScaleMode.NONE. I had the exact same issue with a class I wrote, in which I had to override the width and height getters by adding 1 to the return values of each super method.

这篇关于动作3:(?)的UIScrollBar错误 - 宽度集装箱返回+ 85px的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆