flex - How to manage positions of DisplayObjects in actionscript? -
I use the following code to set the position of a DisplayObject in the center.
obj X = (screen_width - obj.width) / 2; or
obj.x = (parentObj.width - obj.width) / 2;
And I use the following code to show 2 objects vertically.
obj2.x = obj1.width + interval
And I want to show the 2 objects vertically and the following code to determine the position of the center I use.
var obj3: Sprite = new Sprite; Obj3.addChild (obj1); Obj3.addChild (obj2); Obj2.x = obj1.width + interval; Obj3.x (screen_width - obj3.width) / 2;
Is the above code a good way to manage the display object's position?
Are there better and simpler ways to do this?
OK You can also add them to HG Group or VGUP, (or Hx and Vibox if you are using Flex 3). But when I want to implement the vertical layout without using these types of objects, I usually make the "update ()" method (note that the following code may contain syntax errors: this is just the algorithmic example Form):
Private function updates (): Vertical difference between the difference of zero {// elements: int = 4; // Alert height var cumuledHeight: number = 0; // Number of elements var n: int = numElements; // Element in each loop: o: descriptive element; (Var i: int = 0; i & lt; n; i ++) {// element o = getElementAt (i); // sets its vertical position o.y = cumuledHeight + gap * i; // decreases a certain height + = o. height; }}
Comments
Post a Comment