开发者

Dynamically made Sprite Object has Margin/Padding on Bottom

开发者 https://www.devze.com 2023-01-17 03:52 出处:网络
Ok, I have no idea why this is happening. I\'m made an Item class which extends the Sprite class, the Item class basically has a few checkmarks & labels at the moment.

Ok, I have no idea why this is happening.

I'm made an Item class which extends the Sprite class, the Item class basically has a few checkmarks & labels at the moment.

Then what I try to do is run through a for loop of items and create Item classes that I want to place one after each other on the y-axis, so I'm reading the Item.height property to find the y of the next I开发者_运维知识库tem in the list.

The problem is for some reason there is always an extra 75 pixels added to the Sprite height at the bottom, no matter how many checkmarks and labels are in each Item class ( varying the height of the Item class ).

Any idea why this is being added and how it can be removed?

I'm having trouble figuring this out, I tried dynamicly calculating and setting the Item.height property but when I do that the Sprite is simply cropped.


It takes one or two frames until the size of an UI component is correctly set (the default height is 100 pixels).

To prevent this behavior call validateNow() on each Flash UI component you add.

var s:Sprite = new Sprite();
var label:Label = new Label();
label.text = "hello";
label.x = 0;
s.addChild(label);
var check:CheckBox = new CheckBox();
check.label = "hello";
check.x = 50;
s.addChild(check);
addChild(s);
trace(s.height); // output: 100

label.validateNow();
check.validateNow();
trace(s.height); // output: 28
0

精彩评论

暂无评论...
验证码 换一张
取 消