You can get the width in pixels if you use measuredWidth instead of 
width.

x = mainCanvas.measuredWidth*.5;

-TH

--- In [email protected], "Angela" <[EMAIL PROTECTED]> 
wrote:
>
> I am actually having the same problem - 
> 
> I have a canvas with the width set to 100%. If I try and get the 
> width in pixels through AS it returns 0.
> 
> If I try the same thing through mxml it works fine.
> 
> So this in AS:
> public function getMiddle():Number {
>      var x:Number;            
>      x = mainCanvas.width*.5;
>      return x;
> }
> 
> --returns 0
> 
> in MXML:
> <mx:Label text="{mainCanvas.width*.5}"/>
> 
> --returns the amount in pixels.
> 
> Anyone out there know how to get the pixel value though AS?
> 
> Angela.
> 
> 
> --- In [email protected], "leo4beer" <leo4beer@> wrote:
> >
> > Accepting MXML attribute's width in percentage in a custom 
component
> > 
> > Hi, I have a component I've created by inheriting UIObject class
> > 
> > In my mxml I have the following lines used for initiating my 
> component:
> > 
> > <my:comp width="400"….
> > 
> > In my AS code I can trace the value of __width, in this case the
> > result will be "400".
> > 
> > My problem is that when I set the value as percentage:
> > 
> > <my:comp width="100%"….
> > 
> > In this case the value of __width is "undefined"
> > 
> > What should I do in order to get the correct value when setting 
the
> > width in percentage and not in pixels??
> > 
> > Thanks
> >
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Check out the new improvements in Yahoo! Groups email.
http://us.click.yahoo.com/6pRQfA/fOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to