Hi Tracy,
Thanks for the response. But i am constructing a string called
Button1, Button2 ... ButtonN and I want to access the element with
the id in mxml document called Button1 which gives me a type error.
So, how can i remove the type error from the following peice of code?
// assuming id's with names Button1 - ButtonN exist
var buttonName:String;
buttonName = "";
for( var i:Number = 1; i <= N ; i++) {
buttonName = "Button"+i;
buttonName.height = buttonName.height + 10;
// What is the right way to set it in flex?
// In JS I would use getElementById(buttonName).height
// What should I use in AS/Flex?
}
Any help is appreciated.
Thanks,
-S-
--- In [email protected], "Tracy Spratt" <[EMAIL PROTECTED]> wrote:
>
> Yes, as long as the components are in scope and you have
instantiated
> them using mxml tags, you can get a reference to them using the id
> property.
>
>
>
> So you can say:
>
> button1.height = button1.height + 10;
>
>
>
> or whatever property you want to set.
>
>
>
> If you have instantiated them using AS addChild, it is a bit more
> difficult.
>
>
>
> Tracy
>
>
>
> ________________________________
>
> From: [email protected]
[mailto:[EMAIL PROTECTED] On
> Behalf Of suman.karumuri
> Sent: Thursday, October 25, 2007 5:11 PM
> To: [email protected]
> Subject: [flexcoders] getElementByID equivalent
>
>
>
> Hi all,
>
> I am a flex noob. I am writing an application in which I have to
> change the height and width of the buttons and other elements in a
> VBox based on some user action.
>
> To do this, I have assigned id's like "button1", "button2" .. to
the
> buttons, I want to modify when the user clicks on a button. I want
> to know if there is a method like getElementById(as in JS) in flex
> using which I can get the object reference given an ID. That way I
> hope to manipulate the buttons and many other elements on the
screen
> easily. Any pointers are appreciated?
>
> Or is there a better way to do it?
>
> Thanks in advance,
> -S-
>