Skip to main content
Known Participant
December 5, 2007
Question

Positioning Component's X & Y

  • December 5, 2007
  • 2 replies
  • 320 views
May I know how do i set the x and y coordinates of components like button and combo box?

This topic has been closed for replies.

2 replies

Inspiring
December 10, 2007
Setting the _x and _y positions might work OK (often it will). But its not the correct way to do it.

V2 components extend UIObject class. So the methods and properties of UIObject should be used to position and size your components. This ensures that the component maintains its internal state correctly and that you get the desired results.

To set the position use

componentIntstance.move(x,y,noEvent);

to set size use:
componentInstance.setSize(width, height, noEvent)

(see docs for explanation of noEvent)

Other properties that your component has that isn't the same an as2 movieclip (and many are readOnly), are
x,y,width,height, scaleX,scaleY,top,right,left,bottom

If you look up your component class in the documentation you should check out the following headings:
Methods inherited from the UIObject class
and
Properties inherited from the UIObject class

E.g. look here for the Button component: http://livedocs.adobe.com/flash/9.0/main/00002587.html#wp3654189
For combo: http://livedocs.adobe.com/flash/9.0/main/00002633.html#wp3138143
Inspiring
December 10, 2007
Use _x and _y property to set x and y position.