Hi,

Searched the forum but cannot find an answer to my problem. Please look at the 
code and offer some advice.

My code is called Highlight.mxml if I put it in a normal VBox container and 
call setText it sizes correctly.

If I create it as a child in my own component which extends UIComponent, I 
cannot get it to size at all, its always width = 0 even though I do see 
measuredWidth reported correctly.

I wanted this component to size itself based on what is inside the textfield. 
So if it is a child of my component I still would like it to be the size of the 
text.

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"; 
                creationComplete="creationComplete()"
                backgroundColor="0xffffff" 
                borderColor="0x628297" 
                borderThickness="1" 
                borderStyle="solid">
        <mx:Script>
                <![CDATA[
                        import flash.filters.DropShadowFilter;
                
                        private var str:String;
                        
                        private function creationComplete():void
                        {
                                this.filters = [new DropShadowFilter(4, 45, 
0x333333, 0.5) ];
                        }
                        
                        override protected function commitProperties():void 
                        {
                                super.commitProperties();
                                
                                txt.text = this.str;
                                invalidateSize();
                                invalidateDisplayList();
                        }
                        
                        override protected function measure():void 
                        {
                                super.measure();
                                
                                measuredWidth = measuredMinWidth = 
txt.getExplicitOrMeasuredWidth();
                                measuredHeight = measuredMinHeight = 
txt.getExplicitOrMeasuredHeight();
                        }
                        
                        override protected function 
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void 
                        {
                                super.updateDisplayList(unscaledWidth, 
unscaledHeight);
                                //this.setActualSize(txt.width, txt.height);
                        }
                        
                        public function setText(str:String):void
                        {
                                this.str = str;
                                invalidateProperties();
                        }

                ]]>
        </mx:Script>
        <mx:Label id="txt" text="100" color="0x000000"/>
</mx:Canvas>

Reply via email to