Hi rabin,
the width of the component is available once it complete the
lifecycle ( creation complete)
i have updated ur code . you can refer it below
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
minWidth="955" minHeight="600"
creationComplete="init()" >
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.FlexEvent;
import spark.components.Label;
private var label:Label;
private function init():void {
label = new Label()
label.addEventListener(FlexEvent.CREATION_COMPLETE,
function (event:Event):void {
Alert.show("After LifeCycle : "+String(label.width));}
);
label.text = "Hello World";
addElement(label);
Alert.show("Before Enntering LifeCycle :
"+String(label.width));
}
]]>
</fx:Script>
</s:Application>
//
cheers
shavine
On Nov 3, 10:37 pm, Brijesh verma <[email protected]> wrote:
> hi,
>
> while adding lables from script u can set the width but cannot retrieve
> unless unless the width of label isn't fixed. but if u us spark lib object
> of label in mxml tag u will get the width.
>
> Regards
> Brijesh Kumar
> Flex-Flash Developer
> 9871746836
>
> On Wed, Nov 3, 2010 at 2:15 PM, rabin <[email protected]>wrote:
>
> > Hi.
>
> > I want the width of Label control. But unable to do that. Any help ?
>
> > <?xml version="1.0" encoding="utf-8"?>
>
> > <s:Application
> > xmlns:fx="http://ns.adobe.com/mxml/2009"
> > xmlns:s="library://ns.adobe.com/flex/spark"
> > creationComplete="init()">
>
> > <fx:Script>
>
> > <![CDATA[
>
> > import mx.controls.Alert;
>
> > import spark.components.Label;
>
> > private var label:Label
>
> > private function init():void
>
> > {
> > label = new Label()
> > label.text = "Hello World";
> > addElement(label);
>
> > Alert.show(String(label.width));
>
> > }
>
> > ]]>
>
> > </fx:Script>
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Flex India Community" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<flex_india%[email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/flex_india?hl=en.
--
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en.