Copy link to clipboard
Copied
Hi all,
I am new to flash and ActionScript 3.0.I am learning ActionScript 3.0.
My requirement/need is the AS3 code for placing any type of Component(viz., Button, CheckBox, ComboBox, ListBox, radiobutton, Slider, Scrollbar,Label,TextField, etc.,) on the stage with desired width,height, X and Y parameters(values) which we mention in "Properties" tab of Properties Window in flash. Hence, What i need is, (say)a generic ActionScript 3.0 method/function, which places any of the components present in "Components Panel" onto the stage.
i.e., As per my idea, the function prototype or signature may be like this:
function addComponent(int <width>, int <height>, int <XPos>, int <YPos>)
Plzzz... Can anyone help me in this context.... It is a general query i think so. i.e., A basic programmer's task for defining a function for my requirement. I think, if I want to add a Button onto the stage at 100,100 pixel position and the button component's width and height are 50,50 respectively, (i.e., button.X=button.Y=100 && button.width=button.height=50).
So, a button must be placed at 100,100, then, the sample code looks like this:
Button <btn_instance> = new Button(); //creates Button instance
<btn_instance>.addComponent(50,50,100,100);// properties of button.
I hope someone will help me.
Thanks in advance..
Srihari.Ch
Copy link to clipboard
Copied
(OTTOMH) you could have a function similar to:
function placeComponent( container:DisplayObjectContainer, component:UIComponent, w:int, h:int, xpos:int, ypos:int ):void
{
container.addChild( component );
component.move( xpos, ypos );
component.setSize( w, h );
}
called with:
var b:Button = new Button();
placeComponent( this, b, 100, 20, 200, 200 );
You were alost there
Copy link to clipboard
Copied
One problem you may find is that you can't add a component that isn't in the library, so your swf would need to include every kind of component you might add later.