- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
public override function updateDisplayList(
unscaledWidth:Number, unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
if (super.target.numElements < 1) return;
var coefficient:Number, child:DisplayObject, element:IVisualElement,
matrix:Matrix;
for (var i:uint; i < super.target.numElements; i++) {
element = super.target.getElementAt(i);
child = element as DisplayObject;
if (child) {
child.scaleX = child.scaleY = 1;
matrix = child.transform.matrix;
matrix.a = 1;
matrix.d = 1;
child.transform.matrix = matrix;
trace("child class is:", getQualifiedClassName(child),
getQualifiedSuperclassName(child));
if (child is Group) {
trace("child is group");
(child as Group).resizeMode = ResizeMode.SCALE;
}
// if the difference between the container width and the content
// width is less then the difference between the container's
// height and the content's height, set the content to the
// width of the container, adjusting the content's height to
// match the scale ratio of it's width
if (element.width / element.height <
super.target.width / super.target.height) {
if (child is SpriteVisualElement) {
coefficient = super.target.height / element.height;
element.height = super.target.height;
element.width *= coefficient;
} else {
child.height = super.target.height;
child.scaleX = child.scaleY;
}
} else {
if (child is SpriteVisualElement) {
coefficient = super.target.width / element.width;
element.width = super.target.width;
element.height *= coefficient;
} else {
child.width = super.target.width;
child.scaleY = child.scaleX;
}
}
if (child is UIComponent) {
(child as UIComponent).validateDisplayList();
}
child.x = (super.target.width - child.width) / 2;
child.y = (super.target.height - child.height) / 2;
} else {
// Rect, BitmapImage and couple more components fall
// under this category. Let's do our best effort at
// scaling those
if (element.width / element.height <
super.target.width / super.target.height) {
coefficient = super.target.height / element.height;
element.height = super.target.height;
element.width *= coefficient;
} else {
coefficient = super.target.width / element.width;
element.width = super.target.width;
element.height *= coefficient;
}
element.x = (super.target.width - element.width) / 2;
element.y = (super.target.height - element.height) / 2;
if (element.x < 0 || element.y < 0) {
throw new Error("Element would be positioned outside its container");
}
trace("Child is not a display object", super.target.getElementAt(i));
}
}
}
Как Адоб сделал жизнь флекс-разработчиков интересной и насыщенной событиями.